-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.py
38 lines (33 loc) · 1.26 KB
/
Server.py
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
## page 32
import socket
print "start:"
print "Waiting for data from Client..."
##creating server ##
server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 1729))
server_socket.listen(2)
(client_socket, client_address) = server_socket.accept()
client_data = client_socket.recv(1024)
print "data the client sent:" + client_data
print "Client-Data = " + str( tuple(client_address) )
print "Sending to client the following msg: connected to server, data sent to server -" + client_data
client_socket.send("connected to server, data sent to server - " + client_data)
flag = 0
while flag == 0:
print "keep session (y/n)?"
ans = raw_input()
if ans == 'y' :
print "Waiting for data from Client..."
server_socket.listen(2)
(client_socket, client_address) = server_socket.accept()
client_data = client_socket.recv(1024)
print "data the client sent:" + client_data
print "Client-Data = " + str( tuple(client_address) )
print "Sending to client the following msg: connected to server, data sent to server -" + client_data
client_socket.send("connected to server, data sent to server - " + client_data)
else:
flag = 1
client_socket.close()
#here we choose to end the session with the client and can connect another client#
server_socket.close()
## serverrr