Note that there are some explanatory texts on larger screens.

plurals
  1. POCan the python client tcp socket be used for multiple sends?
    text
    copied!<p>I tried using a socket for 2 sends. The first one succeeds and the next one does not. From the <a href="http://docs.python.org/howto/sockets.html" rel="nofollow">http://docs.python.org/howto/sockets.html</a> it would appear that multiple sends should be allowed. For Better or worse, I don't really need to read from the socket. I have used twisted, but for the present purpose, I would like to stick to a socket, if I can help it(partly because I am using it within an application already using twisted to communicate.. this is a seperate connection).</p> <p>"When the connect completes, the socket s can be used to send in a request for the text of the page. The same socket will read the reply, and then be destroyed. That’s right, destroyed. Client sockets are normally only used for one exchange (or a small set of sequential exchanges)."</p> <p>return value for the send that succeeds = 35 return value for the send that FAILS = 32</p> <p>code with some minor editing to remove any business logic.</p> <pre><code>self._commandSock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) def sendPrereqs(self,id,prereqs): self._commandSock.connect(self._commandConnection) #parse prereqs temp = prereqs.split(',') for pair in temp: tup = pair.partition(':') try: command = 'some command' logging.info('sending command: ' + command) ret = self._commandSock.send(command) if ret == None: logging.info('send called successfully: ' + command) else: logging.info('socket returned non-None: ' + str(ret)) except: print 'Unexpected Exception ', sys.exc_info()[0]() print sys.exc_info() #logging.info('Unexpected Exception '+ str(sys.exc_info()[0]())) #logging.info(' ' + str(sys.exc_info())) self._commandSock.close()` </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload