T
Tor Erik Sønvisen
Hi
How can I determine the type of a socket (TCP or UDP) object?
regards tores
How can I determine the type of a socket (TCP or UDP) object?
regards tores
Tor said:How can I determine the type of a socket (TCP or UDP) object?
Peter said:Tor said:How can I determine the type of a socket (TCP or UDP) object?
In what context? Do you have some code that gets passed a socket object
but it could have been created with either SOCK_STREAM or SOCK_DGRAM?
And you want a way of determining by looking just at the object passed
in which type it is? (I could make other guesses, but let's start with
that... ;-) )
How about this:
['__class__', .... '_sock', 'accept', 'bind', 'close'
, 'connect', 'connect_ex', 'dup', 'fileno', 'getpeername',
...'setblocking', 'setsockopt', 'settimeout', 'shutdown']
Let's see... what looks good here?
<socket object, fd=1912, family=2, type=1, protocol=0>
Maybe that type field?
Reinhold said:Heh. The type field isn't publicly accessible (yet). There is a
patch on SF for this, in the meanwhile you'll have to parse the
__repr__ output.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.