strange problem with socket.accept()

Daniel Giddings daniel.giddings at gmail.com
Wed May 30 05:59:37 PDT 2007


Perhaps the output is not being flushed before the socket blocks your 
thread waiting for a user?

Charma wrote:
> hello,
> I have a very strange problem with the accept function of TpcSocket. I 
> programmed a mini-server who is waiting for a user and does something as 
> soon a user has connected(this has no concern) anyway, i got this part 
> of code:
> 
> ...
> scope TcpSocket server = new TcpSocket( );
> Socket user;
> server.blocking(true);
> server.bind( addr );
> server.listen( 10 );
> 
> ...
> 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?
> thanks


More information about the Digitalmars-d-learn mailing list