-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsliding_serv.py
More file actions
36 lines (36 loc) · 811 Bytes
/
sliding_serv.py
File metadata and controls
36 lines (36 loc) · 811 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
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind(('127.0.0.1',2231))
s.listen(5)
input=raw_input("enter the data to be transmitted : ")
client,address=s.accept()
print "sending frames to :"+str(address)
window=4
frames=[]
for k in input:
frames.append(k)
print frames
count=0
while True:
if len(input)-count>4:
window=4
else:
window=len(input)-count
if window<=0:
break
temp=[]
for l in range(count,count+window):
temp.append(str(l))
client.send(''.join(frames[count:count+window])+' '+' '.join(temp))
recv=client.recv(1024)
if(int(recv)==0):
count+=window
continue
else:
frameno=client.recv(1024)
frameno=int(frameno)
print frameno
client.send(''.join(frames[frameno:count+window])+' '+' '.join(temp[frameno:]))
count+=window
client.send("exit")
s.close()