jython socket sendall

Mark Fink mark at mark-fink.de
Sat Feb 18 03:08:55 EST 2006


Hi there,
I am about to port a server application from Java to Jython. For the
socket part I found some examples written in Python. I have problems to
figure out the socket part of the application. In Jython 2.1 the
sendall function is missing?

    def establishConnection(self):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        print type(self.host), repr(self.host)
        print type(self.port), repr(self.port)
        self.socket.connect((self.host, self.port))
#        self.socketOutput = self.socket.getOutputStream()
        self.socketOutput = self.socket
#        self.socketReader = StreamReader(self.socket.getInputStream())
        self.socketReader = self.socket
        bytes = self.makeHttpRequest().encode("UTF-8")
        print type(bytes), repr(bytes)
        self.socketOutput.sendall(bytes)
#        self.socketOutput.flush()
        sys.stdout.write("http request sent\n")

-Mark




More information about the Python-list mailing list