Re: Sockets, non-blocking connect and pool
From: Valentin Nechayev (netch_at_segfault.kiev.ua)
Date: 08/25/03
- Previous message: Derk Gwen: "Re: What protects Unices from Virus like attacks ??"
- In reply to: Miha Lesjak: "Sockets, non-blocking connect and pool"
- Next in thread: Miha Lesjak: "Re: Sockets, non-blocking connect and pool"
- Reply: Miha Lesjak: "Re: Sockets, non-blocking connect and pool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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-
- Previous message: Derk Gwen: "Re: What protects Unices from Virus like attacks ??"
- In reply to: Miha Lesjak: "Sockets, non-blocking connect and pool"
- Next in thread: Miha Lesjak: "Re: Sockets, non-blocking connect and pool"
- Reply: Miha Lesjak: "Re: Sockets, non-blocking connect and pool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|