verifying type of socket object?

Peter Wang pzw1 at cor-no-spam-nell.edu
Thu Nov 1 13:54:41 EST 2001


how very odd.  i'm running PythonWin version 2.1:

"PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on
win32."

this may be a windows socket issue.  when i run the test code on
Python 2.0 under linux, i get the same results as you.  perhaps
someone more familiar with the python socket library under windows can
shed some light here?

-peter



On Thu, 01 Nov 2001 18:02:33 GMT, Thomas Jensen
<thomasNO at SPAM.obscure.dk> wrote:

>Peter Wang <pzw1 at cor-no-spam-nell.edu> wrote in
>news:+YrhO+rceV33qbXjWckIp8NUkWP4 at 4ax.com: 
>
>> in my code, i'd like to verify that i get passed a socket object.
>> however, i'm having some trouble figuring out what exactly
>> represents the "socket type".  the main problem is that
>> socket.socket() doesn't return instances of socket.SocketType:
>
>It does here, se below
>
>>>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>>>> socket.SocketType <type 'socket'> isinstance(x,
>>>>> socket.SocketType) 0 x <socket._socketobject instance at
>>>>> 011232A4> isinstance(x, socket._socketobject) 1 
>
>Whats your system and Python version?
>(Mine is Python 2.1.1 on FreeBSD4.4-RELEASE)
>Here's what I got:
>
>>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>>> socket.SocketType
><type 'socket'>
>>>> isinstance(x, socket.SocketType)
>1
>>>> x
><socket object, fd=8, family=2, type=1, protocol=0>
>>>> isinstance(x, socket._socketobject)
>0
>
>And adding:
>
>>>> type(x) == socket.SocketType
>1




More information about the Python-list mailing list