Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

socket exception python

#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.    
Comment

PREVIOUS NEXT
Code Example
Python :: how to create staff account in django 
Python :: increment python 
Python :: django filter queryset by date 
Python :: python turtle 
Python :: selenium chrome options suppress warnings python 
Python :: make sns heatmap colorbar larger 
Python :: tuple comprehension python 
Python :: taking array input in python 
Python :: progress bar python text 
Python :: np.where 
Python :: search for a word in pdf using python 
Python :: how to create python environment 
Python :: how to get the parent class using super python 
Python :: __str__ method python 
Python :: how to add a file to an email in python 
Python :: how to add to the end of an array python 
Python :: boids algorithm 
Python :: gradient boosting regressor 
Python :: how to clear dictionary in python 
Python :: count specific instances in a columb in pandas 
Python :: export some columns to csv pandas 
Python :: Drop multiple columns by name 
Python :: Python Selenium import WebElement 
Python :: python raise exception 
Python :: matplotlib savefig legend cut off 
Python :: how to get first element of array in python 
Python :: adding one element in dictionary python 
Python :: python endwith 
Python :: How to calculate distance without numpy 
Python :: standardscaler 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =