Files
Hacking-with-Python/04/server.py

19 lines
354 B
Python
Raw Normal View History

2020-11-12 17:02:10 +08:00
import socket
2020-12-04 22:11:58 +08:00
host = "localhost"
2020-11-12 17:02:10 +08:00
port = 9337
sock_ = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock_.bind((host,port))
sock_.listen(1)
print("\nServer started...\n")
conn,addr = sock_.accept()
print("Connection established with: ",str(addr))
message = "\nThank you for connecting "+str(addr)
conn.send(message.encode("ascii"))
2020-12-04 22:11:58 +08:00
conn.close()