Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created January 23, 2020 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/9bad1aecb55711059163f5f809b78426 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/9bad1aecb55711059163f5f809b78426 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