Python Pengecualian Soket

#The default timeout on my machine is 120 seconds. 
#Perhaps you are not waiting long enough for socket.connect() to return (or timeout)?

#You can try reducing the timeout like this:

import socket

s = socket.socket()
s.settimeout(5)   # 5 seconds
try:
    s.connect(('123.123.123.123', 12345))         # "random" IP address and port
except socket.error, exc:
    print "Caught exception socket.error : %s" % exc
    
#Note that if a timeout is explicitly set for the socket, 
#the exception will be socket.
#timeout which is derived from socket.error 
#and will therefore be caught by the above except clause.    
Asif Iqbal Paracha