출처 stackoverflow.com/questions/25447803/python-socket-connection-exception
Python socket connection exception
I have a socket-connection going on and I wanna improve the exception handling and Im stuck. Whenever I use the socket.connect(server_address) function with an invalid argument the program stops, but
stackoverflow.com
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
소켓 연결 디폴트 연결 시도시간 120초
줄이고 싶다면 settimeout() 이용
'[공부용]참고 사이트 모음 > [python]' 카테고리의 다른 글
[Pythone 실행파일] 윈도우/리눅스/맥에서의 실행파일 (0) | 2020.11.19 |
---|---|
CentOS7에 PIP 설치하는 방법 (0) | 2020.11.19 |
소켓 프로그래밍 HOWTO (0) | 2020.11.17 |
Socket Programming in Python (0) | 2020.11.17 |
처음코딩 파이썬 13 지역별, 전역변수 (0) | 2020.11.17 |