Hello there
    I am experimenting with a simple python script which establishes a TCP 
connection, over GPRS, to a server. It then periodically sends a small block of 
data (60 bytes or so) to the server.

I then disconnect the GPRS antenna on this client machine (I am actually 
investigating the behaviour of an independant bit of C++ code; the python is 
really being used as a test bench).

What I then see is that the number of bytes in the socket's output buffer 
builds up, and I then get a ePIPE exception (~SIGPIPE signal) in my script.

Now my copy of Richard Steven's 'Unix Network programming' says:

‘when a process writes to a socket that has received an RST, the SIGPIPE signal 
is sent to the process’

My python code is very simple: something like:

{{{
# setup

gSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
gSock.connect((IP_ADDR, IP_PORT))

p = MyPacket()
while 1:
    try:
        gSock.send(p)
    except socket.error, e:
        # display exception
    except IOError, e
        # ePIPE exception encountered here - but why?

    time.sleep(15)

}}}

I am trying to understand how the ePIPE exception can occur, given my scenario, 
and whether it is due to my using Python, or might also be applicable to my C++ 
code. Surely, if I have disconnected the antenna, the server will have had no 
opportunity to send an RST? Is there another mechanism that might be causing 
the ePIPE?

I'm running Python 2.7.4 under x86 Kubuntu Linux, and python 2.4 on an embedded 
ARM Linux.

Thanks for any thoughts.

    J^n



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to