python-scripts/scripts/Socket_Programming_Python/server1.py

12 lines
379 B
Python
Raw Normal View History

2022-10-09 09:23:49 +00:00
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"))