mirror of
https://github.com/yawaflua/Minecraft_server_creating-BETA-.git
synced 2025-12-10 04:19:33 +02:00
1.0.0
Add some function!
This commit is contained in:
18
ip_adress.py
Normal file
18
ip_adress.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import socket
|
||||||
|
|
||||||
|
HOST = os.read('my_ip.txt') # 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!
|
||||||
Reference in New Issue
Block a user