Jython socket typecasting problems

Diez B. Roggisch deets at nospam.web.de
Sat Feb 11 12:30:09 EST 2006


> This is the code section of my server class (I cut this from a Python
> example):
>     def establishConnection(self):
>         self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>         self.socket.connect((self.host, self.port))
> Do I have to use explicit typecasting? How can this be achieved?

There is no such thing as explicit casting in python. You can coerce 
values to values of another type - e.g. float("1.0"), and there are some 
"magic" methods to support that (for that example __float__)

However, that doesn't seem to be your problem. You just pass the wrong 
arguments, which makes the jython wrapping punke on you as only certain 
types can be dealt with.

To me this looks as if you are supposed to do it like this:

self.socket.connect(self.host, self.port)

Note the missing parentheses.

Diez



More information about the Python-list mailing list