Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
TCP help

 
Post new topic   Reply to topic Printable version
 View previous topic  Looking for fast random number algorit... Post :: Post Creating a ZIP archive and adding file...  View next topic  
Author Message
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Fri Mar 17, 2006 3:15 am    Post subject: TCP help Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Mar 17, 2006 5:45 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Fri Mar 17, 2006 1:56 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Mar 17, 2006 10:05 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Fri Mar 17, 2006 11:04 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sat Mar 18, 2006 1:22 am    Post subject: Reply to topic Reply with quote

I might be missing something, but couldn't you set the socket to non-blocking after you connect?
Back to top
View users profile Send private message Add User to Ignore List Send email
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 661 page(s) served in previous 5 minutes.

phpBB Created this page in 0.456355 seconds : 31 queries executed (80.3%): GZIP compression disabled