Learning asynchronous sockets in D (well actually C...)

Jarl André" <jarl.andre at gmail.com> Jarl André" <jarl.andre at gmail.com>
Sat Jun 23 12:22:18 PDT 2012


The learning curve has been from like zero to "something". I am 
still grasping for some fundamental knowledge that I need to 
fully "get" whats going on. Had to read documentation for sockets 
in C to understand anything at all. That says a lot. Coming from 
BufferedReader hell in Java and did never "get" Java nio.

Looking at the Splat library, it was crude, and I didn't like the 
fact that it was D1. So I converted it to D2. Happy now, it 
works. My plan is to implement splat in the background inside of 
my simple socket server library. At this moment I have made a 
simple parrot server that currently replaces my old server in 
echoserver.d. So a bit of testing going on there atm.

I have learned the pattern "one person that runs back and forth 
with a bucket and fills it up and dumps it accordingly for each 
socket" is actually very effective. This is not very different 
from how i have implemented my simple socket server, except in my 
version i spawned threads that communicated and waited directly 
on the sockets. The parent thread only accepts sockets, I had 
Socket.select(sset,null,null); that in effect allows my spawned 
threads to do anything they wish for. Think I'll replace the 
inner contents of my old simple server with splat code.

Any pointers to what I should do next? Vibed is not an option. I 
do not like the approach. To much hassle for same result. I thnk 
the main reason for not using Vibed is that it is tightly 
connected to a toolchain. I like to have software that is 
independent.

https://github.com/jarlah/d2-simple-socket-server


More information about the Digitalmars-d-learn mailing list