strange problem with socket.accept()

Charma Motoko_Kusanagi at web.de
Wed May 30 05:50:01 PDT 2007


Paul Findlay Wrote:

> > while(!killServer)
> > {
> > writef( "Waiting for user..." ); // **
> > user = server.accept( );
> > writef("[OK]")
> > ...
> > }
> 
> > Now my problem is that the line marked with ** is only displayed when a
> > user connects... which is very strange... i can't figure out the problem,
> > since i tell him to FIRST write that line and THEN wait for a user...
> > Any ideas?
> Output buffering? Since server.accept() blocks you have to wait for the user
> to connect until writef next called, whereupon the buffered output may be
> flushed?
> 
> Maybe try something like the following instead
> 
> import std.c.stdio;
> 
> // ...
> while(/*...*/)
> {
>     writef( "Waiting for user..." );
>     fflush(stdout); // or flushall();
>     // ...
> }
> 
> Yes, I am just guessing. Perhaps best to ask in digitalmars.D.learn
> 
>  - Paul


i do know that accept blocks... but it is called AFTER the writef... so it should black AFTER it... i still don't get it...



More information about the Digitalmars-d mailing list