##// END OF EJS Templates
First beam is loaded by default after sending the beam file to the control modules.
First beam is loaded by default after sending the beam file to the control modules.

File last commit:

r104:105
r230:231
Show More
client.py
68 lines | 1.4 KiB | text/x-python | PythonLexer
import socket
import string
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
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
i=1
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "192.168.1." + str(i)
s.connect((host, 5500))
fd = open("input3.txt","r")
FileList = fd.readlines()
data = "".join(FileList)
cmd = "SNDF"
dfl = 0
lng = int2str(dfl)
msg = "jro" + "abs" + "clnt_01" + "clnt_02" + lng + cmd + data + "0" #
lmsg = len(msg)
lng = int2str(lmsg)
msg = "jro" + "abs" + "clnt_01" + "clnt_02" + lng + cmd + data + "0" #
s.send(msg)
print "Enviado " + str(len(msg)) + " bytes."
recibido = s.recv(512)
print "Recibido: " + recibido
s.close()