Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import select
- import errno
- s = socket.socket()
- s.setblocking(0)
- try:
- s.connect(('14.215.177.39', 80))
- except socket.error, v:
- err = v[0]
- if err == errno.EINPROGRESS:
- print "socket %d started connect..." % s.fileno()
- while True:
- r = [s]
- w = [s]
- x = [s]
- r,w,x= select.select(r,w,x,1)
- print "r=%s,w=%s,x=%s" % (r,w,x)
- if len(w) > 0:
- try:
- s.recv(1, socket.MSG_PEEK)
- except socket.error, v:
- if v[0]== errno.EINPROGRESS:
- print "socket %d still connecting.." % s.fileno()
- continue
- print "socket %d connectd." % s.fileno()
- break
Add Comment
Please, Sign In to add comment