-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathServer.py
More file actions
42 lines (30 loc) · 752 Bytes
/
Server.py
File metadata and controls
42 lines (30 loc) · 752 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
import sys
import socket
from _thread import *
server = '192.168.1.105'
port = 5555
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try :
s.bind((server, port))
except socket.error as e:
str(e)
def client(conn):
reply = ''
while True:
try :
data = conn.recv(2048)
reply = data.decode('utf-8')
if not data:
print("Disconnected")
else :
print("still connected Bro")
conn.sendall(str.encode(reply))
except:
break
conn.close()
while True:
s.listen()
print("not connected")
conn, addr = s.accept()
print("connected to", coon, addr)
start_new_thread(client, (conn, ))