In PHP I just did: $fp = @fsockopen(irc.myserver.net, 6667, $errno, $errstr, 2);
Does Python 2.X also have a function like PHP's fsockopen()
? If not how else can I check if a server on port 6667 is up or not?
The socket module can be used to simply check if a port is open or not.
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('irc.myserver.net', 6667))
if result == 0:
print "Port is open"
else:
print "Port is not open"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With