Files
Minecraft_server_creating-B…/ip_adress.py
Dima YaFlay 90c0448b8d 1.0.1
fixing bugs
2021-11-21 18:42:03 +03:00

20 lines
600 B
Python

import socket
ip = open('my_ip.txt')
ip_adress = ip.read()
HOST = ip_adress # Standard loopback interface address (localhost)
PORT = 65432 # Port to listen on (non-privileged ports are > 1023)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
if data == b'say hello':
print("hello")
# Thanks Victor VosMottor from stackoverflow!