is there any way to queue packets to a socket in Python? I ve been looking for something like the libipq
library, but can t find anything equivalent.
Here s what I m trying to accomplish:
- Create tcp socket connection between server and client (both under my control).
- Try transmitting data (waiting for connection to fault -- e.g. client loses connectivity because of shutting laptop)
- Catch
SocketException
and hold on to the data that was trying to be sent while keeping the remaining data waiting (in a Queue?) - Enter in to loop trying to reconnect (assuming that success is inevitable)
- Create new socket upon success
- Resume data transmission
Any suggestions? Can Twisted do this? Do I need to involve pcapy
? Should I do this (sockets, queues, etc) in C and use Boost to make hybrid code?
Thanks in advance.
Edit 1:
Response to Nick:
I left out the fact that the data I ll be transmitting will be generalized and unending -- think of this app sitting under an ssh session (i m not in any way trying to peek into the packets). So, the transmission will be bilateral. I want to be able to go from the office to my home (closing my laptop in between), open the laptop at home and continue in my session seamlessly. (I know SCREEN exists). This might lead you to wonder how it d work without proxies. It won t, I just haven t explained that design. Blockquote
With the added context, I should also say I won t have to catch a SocketException
on the server side since that machine will be (or assume to be) fixed. When the client figures out that it s got connectivity again, it ll just re-connect to the server.