Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created January 21, 2020 13:14
Show Gist options
  • Save BMU-Verlag/d4830278ca64c8c68c9aed9816a7149f to your computer and use it in GitHub Desktop.
Save BMU-Verlag/d4830278ca64c8c68c9aed9816a7149f to your computer and use it in GitHub Desktop.
from header_utils import format_message
import socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((socket.gethostname(), 5555))
server_socket.listen(10)
print (f'Listeing on {socket.gethostname()}:{5555}')
while True:
client_socket, client_address = server_socket.accept()
print(f'Established connection to {client_address[0]}:{client_address[1]}')
client_socket.send(bytes(format_message('Hello there, how are you?'), 'utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment