Re: Sockets, non-blocking connect and pool

From: Valentin Nechayev (netch_at_segfault.kiev.ua)
Date: 08/25/03

  • Next message: Måns Rullgård: "Re: What protects Unices from Virus like attacks ??"
    Date: Mon, 25 Aug 2003 12:21:52 +0300
    
    

    >>> Miha Lesjak wrote:

    ML> I would like to know, how to get information about non-blocking
    ML> connect call; especially when is it finished and if it finished
    ML> successfully or not. I know I can do that with select, but that
    ML> is not what I am into. I would like to use the pool system call.

    ML> The problem is that I get POLLIN event as a result every time I
    ML> connect (even if I connect to a not reachable IP) and then the
    ML> call to recv fails (and there is where I handle connect error -
    ML> I have a variable to remember that the socket is in connecting
    ML> state).

    This is correct. POLLIN doesn't say read() or recv() will be successful.
    It only says it won't block (and, if is on nonblocking socket, will say
    something another than EAGAIN). This is design principle and this is
    correct design principle.
    For connect(), you should track socket state phase by yourself. Also,
    connection error diagnostics is provided by another tools: checking
    peer address (it isn't set unless connecting succeeded), quering asynchronous
    error code (setsockopt(s,SOL_SOCKET,SO_ERROR))...

    ML> How should I set the pollfd's events and what revents should I
    ML> expect after calling connect and then pool on my socket descriptor?
    s/pool/poll/
    your typo is systematic

    -netch-


  • Next message: Måns Rullgård: "Re: What protects Unices from Virus like attacks ??"

    Relevant Pages

    • Re: SetSockOpt with SO_REUSEADDR parameter
      ... So I create multiple UDP sockets with the same port to send data. ... happening is that you are throwing away the old socket and replacing it with the new ... When the second client is connecting to server, I still get the error code ...
      (microsoft.public.vc.mfc)
    • Re: 4th attempt: UDP Socket Bug
      ... > does function in windows app as the class will show. ... Add a test call returning the connecting user ... changing the socket type to UDP and ... >>> ASPNET added the account to the local administrators ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: NTE5 box - not connected to anything!
      ... I decided to make sure all my filters ... I purchased a replacement NTE5 faceplate from ADSLNation ... The test socket is dead as a dodo. ... Connecting the other to the A-B on the ...
      (uk.telecom.broadband)
    • Re: DSL light flashing
      ... I have an intermittant fault that sometimes prevents me ... connecting to the internet and outlook express. ... connected directly to the socket in my office. ... My extension lead don't make a jot of difference. ...
      (uk.people.silversurfers)
    • Re: Behaviour of winsock send() using tcp
      ... All it does is it points out that UDP messages may also not ... be sent with an async socket. ... TCP always has a buffer ... then what does a successful result actually mean? ...
      (microsoft.public.win32.programmer.networks)