##// END OF EJS Templates

File last commit:

r91:92
r97:98
Show More
client.py
91 lines | 1.7 KiB | text/x-python | PythonLexer
r85 import socket
import string
#import time
r53
r85 def int2bin(n):
n_hex = "%x" %n
ln = len(n_hex)
if ln == 1:
n_hex = "00000" + n_hex
elif ln == 2:
n_hex = "0000" + n_hex
elif ln == 3:
n_hex = "000" + n_hex
elif ln == 4:
n_hex = "00" + n_hex
elif ln == 5:
n_hex = "0" + n_hex
byte1 = n_hex[0:2]
byte2 = n_hex[2:4]
byte3 = n_hex[4:6]
str_len = ""
str_len += "%c" % string.atoi(byte1,16)
str_len += "%c" % string.atoi(byte2,16)
str_len += "%c" % string.atoi(byte3,16)
return str_len
Testing frame transfer without colon.
r91 def int2str(n):
str_n = str(n)
l_n = len(str_n)
if l_n == 1:
str_n = "00000" + str_n
elif l_n == 2:
str_n = "0000" + str_n
elif l_n == 3:
str_n = "000" + str_n
elif l_n == 4:
str_n = "00" + str_n
elif l_n == 5:
str_n = "0" + str_n
return str_n
r85 #ini = time.time()
#sum = 0
#for i in range(11,15):
i=117
#ini1 = time.time()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "192.168.1." + str(i)
Testing frame transfer without colon.
r91 s.connect((host, 5500))
r85
Testing frame transfer without colon.
r91 fd = open("experimento2.abs","r")
Pruebas del servidor con el cliente para transferencia de archivos
r66 FileList = fd.readlines()
r85 data = "".join(FileList)
Pruebas del servidor con el cliente para transferencia de archivos
r66
r85 dfl = 0
Testing frame transfer without colon.
r91 #lng = int2bin(dfl)
lng = int2str(dfl)
r85 msg = "jro" + "abs" + "src" + "cm1" + lng + "cmd" + data + "crc" #
print len(msg)
print msg
lmsg = len(msg)
Testing frame transfer without colon.
r91 #lng = int2bin(lmsg)
lng = int2str(lmsg)
r85
msg = "jro" + "abs" + "src" + "cm1" + lng + "cmd" + data + "crc" #
print len(msg)
Testing frame transfer without colon.
r91 #print msg
r85
Testing frame transfer without colon.
r91 s.send(msg)
r85 #recibido = s.recv(512)
Testing frame transfer without colon.
r91 #print recibido
r85
s.close()
# delay = time.time() - ini1
# sum += delay
# print delay
# time.sleep(0.1)
#print sum