Creating socket.connect while in epoll loop

M

Miki Tebeka

Greetings,

I'm trying to write a reverse TCP proxy using epoll (just for learning).

I've started with the code at http://scotdoyle.com/python-epoll-howto.html and got to https://gist.github.com/3707665.

However, I can't create a new connection. When reaching line 34 (backend.connect), I get the following error (on line 34):
socket.error: [Errno 115] Operation now in progress

I tried moving the socket creation to a different thread, but same problem.
Any ideas how to so fix this? (keep in mind I'm a total newbie in this area).

Thanks,
 
C

calderone.jeanpaul

Greetings,

I'm trying to write a reverse TCP proxy using epoll (just for learning).

I've started with the code at http://scotdoyle.com/python-epoll-howto.html and got to https://gist.github.com/3707665.


However, I can't create a new connection. When reaching line 34 (backend.connect), I get the following error (on line 34):

socket.error: [Errno 115] Operation now in progress

You cannot synchronously set up a new TCP connection using a non-blocking socket. Instead, you begin the connection attempt and it fails with EINPROGRESS and then you use epoll to find out when the attempt completes.

I suggest reading the implementation of a Twisted reactor to see an example of how this is done.

Here are a couple links to get you started:

http://twistedmatrix.com/trac/browser/trunk/twisted/internet/tcp.py
http://twistedmatrix.com/trac/browser/trunk/twisted/internet/epollreactor.py

Jean-Paul
 
M

Miki Tebeka

You cannot synchronously set up a new TCP connection using a non-blocking > socket. Instead, you begin the connection attempt and it fails with EINPROGRESS and then you use epoll to find out when the attempt completes.
OK.
I suggest reading the implementation of a Twisted reactor to see an example of how this is done.
That was the idea, learning.
Thank you very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top