I'm trying to make something that once it is disconnected will automatically try to reconnect. I'll add some more features in later so it doesn't hammer the server but right now I just want to keep it simple and get that part working. The problem is that when I use sock.close I get an error message of
Bad File Descriptor
and if I either use shutdown or just go straight to reconnecting I get:
Transport endpoint is already connected
>>3
one word, THE FORCED INDENTATION OF CODE, thread over.
Name:
Anonymous2008-03-28 12:33
strange
Name:
Anonymous2008-03-28 12:36
you clearly don't understand what the connect() actually does. Do some reading and try again. (Pro-tip: it's a shortcut to bind on a non-specified port)
Name:
Anonymous2008-03-28 12:46
>>5
FIOC won't help if you use a proportional font.
Create a new socket for each connection instead of calling connect() again on the old one.
And while (1): ? Those parentheses are superfluous and misleading.
And dodiscon is convoluted, and inconsistent with doconn (note the n's). Put in the extra typing effort and give them full names, like do_disconnect. But it's not really a disconnect, it's a reconnect, so change the name to reflect that.
While we're on the topic of sockets, I have a question for [spoiler]/prog/[spoiler]:
Say your UNIX application connects to some server, and is doing normal read and write stuff, and then suddenly the socket dies. What do you do? Do you try to reconnect, or do you abort the whole program with an error? Maybe you do some hybrid approach that tries to reconnect a couple times at increasing intervals of time, and then abort after a while.
>>22
Did you mean ExitProcess(NULL, NULL, NULL, NULL, NULL)?
Name:
Anonymous2008-03-29 0:43
>>23
I'm sorry, I use Ubanto, the one true operating system!
Name:
Anonymous2008-03-29 1:25
I crossposted this to 10 different forums and eventually got an answer on IRC. Close doesn't just disconnect the socket, it completely fucking wipes it from the face of the planet. So I just had to create a new one with the same name and it was fixed.