##// END OF EJS Templates
imanay -
r70:71
parent child
Show More
@@ -8,7 +8,7
8 8
9 9 class ABSClient:
10 10
11 def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000):
11 def __init__(self,ipSource="localhost", ipDestino="192.168.1.100", portDestino=7000):
12 12
13 13 self.ipSource = ipSource
14 14 self.ipDestino = ipDestino
@@ -114,19 +114,26
114 114 def configAsServer(self):
115 115
116 116 self.socket_c.bind(self.addr)
117 self.socket_c.listen(1)
118 sc, addr = self.socket_c.accept()
119 self.sc = sc
120 self.answer = addr
121 print "\nServer initialized"
122 117
123 def waitData(self, nbytes = 16384):
118 def waitData(self, nbytes = 1024):
124 119
125 print "\nWaiting some data"
120 print "\nWaiting some client."
121
126 122 if self.mode == "client":
123 # Short data through ethernet
127 124 trama_rx = self.socket_c.recv(nbytes)
128 125 else:
129 trama_rx = self.sc.recv(nbytes)
126 self.socket_c.listen(1)
127 sc, addr = self.socket_c.accept()
128 self.sc = sc
129 self.answer = addr
130 # Big data through ethernet
131 trama_rx = ""
132 while True:
133 tmp = self.sc.recv(nbytes)
134 trama_rx = trama_rx + tmp
135 if trama_rx[-4:] == "quit":
136 break
130 137
131 138 print "\nThis socket has received some data from:"
132 139 print self.answer
@@ -138,14 +145,14
138 145 def sendData(self, cmd, data):
139 146
140 147 if self.portDestino == 7000:
141 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":"
148 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":" + "quit"
142 149 else:
143 150 trama_tx = data
144 151 # Send messages
145 152 if self.mode == "client":
146 153 self.socket_c.send(trama_tx)
147 154 else:
148 self.addr2[0].send(trama_tx)
155 self.sc.send(trama_tx)
149 156 print "Sending message:[" + trama_tx + "]"
150 157
151 158 def __getTrama(self, trama):
@@ -161,9 +168,8
161 168
162 169 return ipSource, ipDestino, cmd, data
163 170
164 def close_socket():
171 def close_socket(self):
165 172 self.socket_c.close()
166
167 173
168 174 #class FTPComm:
169 175 #
@@ -4,7 +4,7
4 4
5 5 class ABSServer:
6 6
7 def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.225", portDestino2=5500, ftpPortDestino=None):
7 def __init__(self,ipSource="localhost", ipDestino="192.168.1.100", portDestino=7000, ipDestino2="192.168.1.225", portDestino2=5500, ftpPortDestino=None):
8 8
9 9 self.ipSource = ipSource
10 10 self.ipDestino = ipDestino
@@ -23,7 +23,7
23 23
24 24 asServer = True
25 25 self.commServerObj = library.TCPComm(self.ipSource, self.ipDestino, self.portDestino, asServer)
26 # self.commClientObj = library.TCPComm(self.ipSource, self.ipDestino2, self.portDestino2)
26 self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2)
27 27 #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino)
28 28
29 29
@@ -34,8 +34,7
34 34 datarpta = "OK"
35 35
36 36 if cmd == "SNDF":
37 # self.sendFile2Modules()
38 pass
37 self.sendFile2Modules()
39 38
40 39 if cmd == "CHGB":
41 40 self.changeBeam()
General Comments 0
You need to be logged in to leave comments. Login now