mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-12-18 16:20:17 +00:00
12 lines
379 B
Python
12 lines
379 B
Python
import socket
|
|
|
|
server_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
|
|
port = 1024
|
|
host = socket.gethostbyname(socket.gethostname()) # get the hostname
|
|
server_socket.bind((host, port))
|
|
server_socket.listen(2)
|
|
while True:
|
|
conn, address = server_socket.accept()
|
|
print("Connection from: " + str(address))
|
|
conn.send(bytes("Socket programming in python","utf-8"))
|