@@ -115,10 +115,16 | |||
|
115 | 115 | def waitAsClient(self, nbytes = 1024): |
|
116 | 116 | print "\nWaiting the server." |
|
117 | 117 | # Short data through ethernet |
|
118 | trama_rx = self.socket_c.recv(nbytes) | |
|
119 | lng = int(trama_rx[20:26]) | |
|
120 | print "\nThis socket has received this data: " + str(trama_rx) | |
|
121 | ||
|
118 | try: | |
|
119 | trama_rx = self.socket_c.recv(nbytes) | |
|
120 | lng = int(trama_rx[20:26]) | |
|
121 | except: | |
|
122 | print "Waiting error" | |
|
123 | trama_rx = "Error" | |
|
124 | lng = 0 | |
|
125 | else: | |
|
126 | print "\nThis socket has received this data: " + str(trama_rx) | |
|
127 | ||
|
122 | 128 | return trama_rx, lng |
|
123 | 129 | |
|
124 | 130 | def sendData2(self, cmd, data, ipDestino): |
@@ -153,10 +159,14 | |||
|
153 | 159 | |
|
154 | 160 | |
|
155 | 161 | def SendAsClient(self, ipDestino, trama_tx): |
|
156 | ||
|
157 | self.socket_c.connect((ipDestino, self.portDestino)) | |
|
158 | self.socket_c.send(trama_tx) | |
|
159 | print "Sending message:[" + trama_tx + "] to: " + ipDestino | |
|
162 | ||
|
163 | try: | |
|
164 | self.socket_c.connect((ipDestino, self.portDestino)) | |
|
165 | except: | |
|
166 | print "Connection error with:" + ipDestino | |
|
167 | else: | |
|
168 | self.socket_c.send(trama_tx) | |
|
169 | print "Sending message:[" + trama_tx + "] to: " + ipDestino | |
|
160 | 170 | |
|
161 | 171 | def __getTrama2(self, trama): |
|
162 | 172 |
General Comments 0
You need to be logged in to leave comments.
Login now