-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunity_server.py
More file actions
49 lines (39 loc) · 919 Bytes
/
unity_server.py
File metadata and controls
49 lines (39 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
"""
A simple echo server,
to test tcp networking code
"""
import socket
print("Port:")
port = input()
host = ''
# port = 50002
backlog = 5
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(backlog)
def send(ms):
ms += "\n"
client.send(ms.encode(encoding='utf_8'))
def receive():
data = client.recv(size).rstrip('\r\n')
return data
def close():
client.close()
client, address = s.accept()
print ("Client connected.")
# while 1:
# client, address = s.accept()
# print ("Client connected.")
# client.send("Hello!\n")
#
# while 1:
# data = client.recv(size).rstrip('\r\n')
# if data:
# if data=="quit":
# client.send("Bye!\n")
# client.close()
# break
# else:
# client.send("You just said: " + data + "\n")