mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-27 22:11:10 +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"))
|