-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver
More file actions
38 lines (33 loc) · 863 Bytes
/
server
File metadata and controls
38 lines (33 loc) · 863 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
#Server na localu
#!/usr/bin/python
import socket
import threading
import sys
#blok klas
class ClientConn:
conn = 0
addr = 0
data = ''
def __init__(self, conn, addr): #konstruktor, ustawiamy polaczenie i wywolujemy odbior wiadomosci
self.conn = conn
self.addr = addr
self.connHndl()
def connHndl(self):
while True:
data = conn.recv(64)
if data:
conn.send(data[::-1])
print data
conn.close()
break
#blok zmiennych
conList = []
#Start server
print 'Witaj w serwerze'
proto = socket.getprotobyname('tcp')
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, proto)
sock.bind(('localhost',9999))
sock.listen(1)
while True:
conn,addr = sock.accept()
client_thread = threading.Thread(target=ClientConn,args=(conn,addr))