Re: select() indicates writability before a non-blocking TCP socket has actually connected



On 2006-10-26, jaswantv@xxxxxxxxxxxxxxxxxx <jaswantv@xxxxxxxxxxxxxxxxxx> wrote:

I am trying to implement a TCP client which can wait until it has a
server to connect to. The idea is that the client will emit periodic
notifications while the server is unavailable. I have used non-blocking
sockets and select() to implement the behaviour where each call to
select() will return if either the connection is made (server starts up

and begins accepting connections) or the timeout expires. If a timeout
occurs, the socket is closed and a new socket along with a new call to
connect() is done.

I have noticed that on Linux select() returns instantly with the
correct FD bit set (indicating the socket is available for writing).

No, it's indicating that a write() call will not block. Which
is true, because it's a non-blocking socket. Using select on a
non-blocking socket doesn't make any sense.

--
Grant Edwards grante Yow! Are you still an
at ALCOHOLIC?
visi.com
.



Relevant Pages

  • Re: How to terminate a socket in CLOSE_WAIT state
    ... FTP Server fixed for certain FTP clients who use both passive ... This was causing a PASSIVE opened socket to be left ... but instead expect the "half close" from the receiver. ... this sends a TCP/IP FIN packet to the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Applet Hangs when submitting data to servlet
    ... to put a time limit on my socket connections and socket reads. ... public void setTimeoutthrows UnknownHostException, ... on our web server. ... private JButton theSubmitButton_, theClearButton_; ...
    (comp.lang.java.programmer)
  • Re: Problem with writing fast UDP server
    ... UDP packets per second. ... socket and threads. ... I wrote a simple case test: client and server. ... The maximum theoretical limit is 14,880 frames per ...
    (comp.lang.python)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)