www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Simple Socket Server Code

reply sybrandy <sybrandy gmail.com> writes:
All,

Does anyone know where I can get a simple example of writing a server in 
D?  Just a stupid little echo server would be fine.  I'm trying to write 
one myself, but for some reason it doesn't seem to be accepting any 
connections.  I figure it's something stupidly simple, but I'm just not 
seeing it.

Perhaps a related question is: is there anything weird about creating a 
server on windows?  I'm currently using D on a windows laptop, so 
perhaps this is a platform issue?  I find it unlikely, but you never know.

Thanks.

Casey
Feb 23 2010
parent reply daoryn <asef sdfv.com> writes:
sybrandy Wrote:

 All,
 
 Does anyone know where I can get a simple example of writing a server in 
 D?  Just a stupid little echo server would be fine.  I'm trying to write 
 one myself, but for some reason it doesn't seem to be accepting any 
 connections.  I figure it's something stupidly simple, but I'm just not 
 seeing it.
 
 Perhaps a related question is: is there anything weird about creating a 
 server on windows?  I'm currently using D on a windows laptop, so 
 perhaps this is a platform issue?  I find it unlikely, but you never know.
 
 Thanks.
 
 Casey

Check the "samples" dir inside the dmd instalation folder. Theres a sample there named "listener.d" that shows how to use D sockets. If you're using DMD2, the listener.d file is broken. You'll have to convert it into D2 yourself.
Feb 24 2010
parent sybrandy <sybrandy gmail.com> writes:
On 02/24/2010 09:00 AM, daoryn wrote:
 Check the "samples" dir inside the dmd instalation folder.
 Theres a sample there named "listener.d" that shows how to use D sockets.
 If you're using DMD2, the listener.d file is broken. You'll have to convert it
into D2 yourself.

I actually did look at that and it is more than I was looking for. I just wanted something akin to "Listen -> Accept -> Process -> Respond -> Repeat." Regardless, it turns out that my understanding was better than I thought. I just had a stupid little bug that I didn't notice was an actual compilation error at first. Guess that's what I get when I try to write code when tired... Anyway, thanks!
Feb 24 2010