Author |
Message |
Mr Ekted Movie Geek
![](images/avatars/6a5b66c9029aa6eac5aef2f530a2b60d4416515a9f6a1.jpg)
Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 17, 2006 3:15 am Post subject: TCP help |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
I'm playing around with some non-SS stuff. It's been so long since I did anything with TCP. I create a socket, make it non-blocking, and connect...
socket()
ioctlsocket()
connect()
At this point connect returns WSAEWOULDBLOCK. Fine. Now I seem to remember being able to ONLY use send()/recv() from this point on, as long as I am careful with the return values. However, I find that if I perform a test to a non-listening server, that I simply get WSAENOTCONN forever. I can't find any documentation that clarifies if this error state is pre-connection, post-connection, or both. I would expect recv() to eventually cause a WSAETIMEDOUT or WSAECONNRESET error, but I never see it, even when the other end aborts the connection.
Any thoughts? _________________ 4,691 irradiated haggis! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Bak ?ls -s 0 in
![](images/avatars/404997118f1ce7de4ddd04696735dba8452b42d283d73.png)
Age:25 Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Mar 17, 2006 5:45 am Post subject: |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
i'd use select with a 0 second timeout and check the return value of send or recv for disconnect as usual |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Mr Ekted Movie Geek
![](images/avatars/6a5b66c9029aa6eac5aef2f530a2b60d4416515a9f6a1.jpg)
Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 17, 2006 1:56 pm Post subject: |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
According to documentation on select()...
read check tells: Connection has been closed/reset/terminated
write check tells: If processing a connect call (nonblocking), connection has succeeded
exception check tells: If processing a connect call (nonblocking), connection attempt failed
But, for example, if the connection has failed, why wouldn't send() or recv() give me that same information? Why should I have to make 3 other checks to see the state of the connection? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Cyan~Fire I'll count you!
![I'll count you! I'll count you!](/images/avatars/thing.jpg)
Age:36 Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Mar 17, 2006 10:05 pm Post subject: |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
I think WSAENOTCONN is both pre- and post-connection. Since it's a connection-oriented protocol, then it makes perfect sense to me to have send() or recv() just produce WSAENOTCONN. Obviously connect() failed (as expected), so you'll have to check its return value before trying any other operations. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Mr Ekted Movie Geek
![](images/avatars/6a5b66c9029aa6eac5aef2f530a2b60d4416515a9f6a1.jpg)
Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 17, 2006 11:04 pm Post subject: |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
I set the socket non-blocking. connect() always fails with WSAEWOULDBLOCK. It sucks that I am forced to use the completely gay function select(), when recv() and send() should be perfectly able to return the socket state. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Mine GO BOOM Hunch Hunch What What
![Hunch Hunch<br>What What Hunch Hunch<br>What What](/images/avatars/hunchhunch-whatwhat.gif)
Age:40 Gender:![Gender:Male Gender:Male](templates/subSilver/images/icon_minigender_male.gif) Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Sat Mar 18, 2006 1:22 am Post subject: |
![Reply to topic](templates/subSilver/images/lang_english/reply_mini.gif) |
|
|
|
I might be missing something, but couldn't you set the socket to non-blocking after you connect? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|