Re: how to know if socket is still connected

2006-07-20 Thread Steve Holden
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Grant Edwards wrote: > > >>If the server has closed the connection, then a recv() on the >>socket will return an empty string "", and a send() on the >>socket will raise an exception. > > > Would that still apply when trying to send a

Re: how to know if socket is still connected

2006-07-20 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Grant Edwards wrote: > If the server has closed the connection, then a recv() on the > socket will return an empty string "", and a send() on the > socket will raise an exception. Would that still apply when trying to send an empty string? -- http://mail.python.or

Re: how to know if socket is still connected

2006-07-19 Thread bryanjugglercryptographer
Grant Edwards wrote: > If the server has closed the connection, then a recv() on the > socket will return an empty string "", after returning all the data the remote side had sent, of course. > and a send() on the > socket will raise an exception. Send() might, and in many cases should, raise a

Re: how to know if socket is still connected

2006-07-18 Thread John J. Lee
Grant Edwards <[EMAIL PROTECTED]> writes: [...] > > Often normal send() and recv() semantics have been mistaught. > > An alert alien, looking at other common APIs in isolation, > > might reasonably wonder whether there is some sort of > > still_ok_to_use() sort of check as part of TCP. As it hap

Re: how to know if socket is still connected

2006-07-18 Thread Laszlo Nagy
[EMAIL PROTECTED] írta: > ok, yeah, thats in my book. > thanks, and no, it isn't enabled. > thanks again for everything > -sk > Another hint: use select.select() on the socket before reading. It will tell you if recv() will block or not. This way you can implement your own async timeout and do

Re: how to know if socket is still connected

2006-07-17 Thread nephish
ok, yeah, thats in my book. thanks, and no, it isn't enabled. thanks again for everything -sk Grant Edwards wrote: > On 2006-07-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> If the server _application_ crashes or exits, then the OS will > >> close the socket and recv() will return "". If

Re: how to know if socket is still connected

2006-07-17 Thread Grant Edwards
On 2006-07-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> If the server _application_ crashes or exits, then the OS will >> close the socket and recv() will return "". If somebody powers >> down the server without warning, or if the server OS crashes, >> or if the Ethernet cable between the I

Re: how to know if socket is still connected

2006-07-17 Thread nephish
> If the server _application_ crashes or exits, then the OS will > close the socket and recv() will return "". If somebody powers > down the server without warning, or if the server OS crashes, > or if the Ethernet cable between the Internet and the server is > cut, then the socket will not be clo

Re: how to know if socket is still connected

2006-07-17 Thread Grant Edwards
On 2006-07-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > oh, sorry, what i mean by dropped is that the server i am > connecting to can close the connection. Then recv() will return "" and send() will raise an exception. > If that happens, i need to know about it. i also need to know > about

Re: how to know if socket is still connected

2006-07-17 Thread nephish
oh, sorry, what i mean by dropped is that the server i am connecting to can close the connection. If that happens, i need to know about it. i also need to know about it if the server i am connecting to just dies. if recv() returns "" is that the same as NONE ? again, sorry, i am still kinda new at

Re: how to know if socket is still connected

2006-07-17 Thread Grant Edwards
On 2006-07-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > hey there, i have a question about this solution. > if i have a > message = socket.recv() > in the script, and the socket connection drops, will the > socket.recv() just wait forever for something to come across > the internet port? or

Re: how to know if socket is still connected

2006-07-17 Thread nephish
hey there, i have a question about this solution. if i have a message = socket.recv() in the script, and the socket connection drops, will the socket.recv() just wait forever for something to come across the internet port? or will it know if the connection is dropped? thanks. -sk Grant Edwards wr

Re: how to know if socket is still connected

2006-07-17 Thread Grant Edwards
On 2006-07-17, Cameron Laird <[EMAIL PROTECTED]> wrote: >>> works well, but sometimes the server drops the connection. so, >>> what i need is something that will let me know if the >>> connection is still ok, if not will reconnect. >> >>If the server has closed the connection, then a recv() on the

Re: how to know if socket is still connected

2006-07-17 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> serverhost = 'xxx.xxx.xxx.xxx' >> serverport = 9520 >> aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> aeris_sockobj.connect((serverhost,s

Re: how to know if socket is still connected

2006-07-16 Thread nephish
cool enough, thanks ! -sk Grant Edwards wrote: > On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> If the server has closed the connection, then a recv() on the > >> socket will return an empty string "", and a send() on the > >> socket will raise an exception. > > > like this ?

Re: how to know if socket is still connected

2006-07-16 Thread Grant Edwards
On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> If the server has closed the connection, then a recv() on the >> socket will return an empty string "", and a send() on the >> socket will raise an exception. > like this ? > databack = aeris_sockobj.recv(2048) > if databack: >

Re: how to know if socket is still connected

2006-07-16 Thread nephish
Grant Edwards wrote: > On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > serverhost = 'xxx.xxx.xxx.xxx' > > serverport = 9520 > > aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > aeris_sockobj.connect((serverhost,serverport)) > > > > while 1: > > do this or

Re: how to know if socket is still connected

2006-07-16 Thread Grant Edwards
On 2006-07-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > serverhost = 'xxx.xxx.xxx.xxx' > serverport = 9520 > aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > aeris_sockobj.connect((serverhost,serverport)) > > while 1: > do this or that with socket, > send and recei

how to know if socket is still connected

2006-07-16 Thread nephish
lo there, i have a simple app that connects to a socket to get info from a server i looks like this serverhost = 'xxx.xxx.xxx.xxx' serverport = 9520 aeris_sockobj = socket.socket(socket.AF_INET, socket.SOCK_STREAM) aeris_sockobj.connect((serverhost,serverport)) while 1: do this or that with