Re: "connect'" returns before server "accept"s




In article <ZqGvf.3224$ZA2.1957@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>, Joseph Dionne <jdionne@xxxxxxxxxxx> writes:
> chengiz@xxxxxxxxxxx wrote:
> > It seems even in a blocking socket world, "connect" can return
> > immediately if the server has been set to "listen" but has not called
> > "accept" yet.
>
> I typically create sockets to non blocking connects, using poll() to wait for
> the socket to become write ready, or time out -- which can be INFINITE is you
> wish.

A non-blocking connect and waiting for the socket to become ready for
writing has precisely the same effect as a blocking connect, for the
OP's purposes. The active-open socket will be ready for writing when
the handshake completes; it does not somehow wait for the server to
call accept (an event which is not signalled to the client).

Of course, if the client sends data before the server calls accept, it
can eventually fill the server's receive window and at that point it
will no longer be ready for writing.

--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx

Some seem to live on credit as naturally as they breathe, and I remember
the surprise of one of these: "What! You don't owe anybody anything! Good
Lord! man, lend me half a sovereign." -- Arthur Ransome
.



Relevant Pages

  • Writing a windows service with a socket interface.
    ... I'm writing a windows service that is accessible via sockets. ... and sends a response back to the client. ... Are there any good resources on writing windows services with socket ... Or perhaps if the IP address of the server was modified while the ...
    (microsoft.public.dotnet.framework)
  • Having a problem with some socket code
    ... Anyway I have it working with threads, as each client connects the socket ... data method that calls recieve directly to get the size of the data in the ... This all works great if I don't use the Poll method to prevent the blocking ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interrupting a socket operation from another thread
    ... Using blocking connect, send, recv calls. ... Are you using a dedicated thread per client? ... close the socket handle but this gives a race condition (on unix ... If you want to shutdown the connection the socket refers to, ...
    (comp.programming.threads)
  • Re: recv blocks although socket is ready
    ... of the members of the interface in my network layer have blocking ... Only one has non-blocking semantics. ... call any socket operation and rely on the socket to block. ... Now I have to implement blocking myself in all other ...
    (microsoft.public.win32.programmer.networks)
  • Re: Async socket & active connections
    ... The "blocking = true" in the disconnect phase seems to solve the ... Socket and TcpClient, ... blocking connection somewhere down the line. ... 300K connections, enough to start worrying... ...
    (microsoft.public.dotnet.languages.csharp)