Jython socket typecasting problems

Kent Johnson kent at kentsjohnson.com
Mon Feb 13 16:05:57 EST 2006


Mark Fink wrote:
> I added the two print lines as recommended:
>         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()
> 
> And more specific information:
> D:\AUT_TEST\workspace\JyFIT\fit>jython JyFitServer2.py 127.0.0.1 1234
> 12
> ['JyFitServer2.py', '127.0.0.1', '1234', '12']
> 127.0.0.1
> org.python.core.PyString '127.0.0.1'
> org.python.core.PyString '1234'
> Traceback (innermost last):
>   File "JyFitServer2.py", line 148, in ?
>   File "JyFitServer2.py", line 31, in run
>   File "JyFitServer2.py", line 98, in establishConnection
>   File "D:\AUT_TEST\Jython21\Lib\socket.py", line 135, in connect
> TypeError: java.net.Socket(): 1st arg can't be coerced to
> java.net.InetAddress or String
> 
> No casting from string to string?? I learned that there is no such
> thing as explicit typecasting. What to do?

The problem is that the second arg is not an int. The second problem is 
that the error message errorneously points to the first arg. See my 
earlier post.

Kent



More information about the Python-list mailing list