Python Socket prüft, ob sie noch angeschlossen sind
def is_still_connected(sock):
try:
sock.sendall(b"ping")
return True
except:
return False
The Nic
def is_still_connected(sock):
try:
sock.sendall(b"ping")
return True
except:
return False
import socket
s = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(("localhost", 10000))
except socket.error as e:
print e
OUTPUT
[Errno 111] Connection refused