are sockets bloking on WinTN...

Pete pete at ipartners.pl
Mon Jul 30 06:24:01 EDT 2001


Hi pythoniers,

According to docs I never should receive (10035, 'The socket operation could
not complete without blocking') error with blocking sockets. But on my NT
box this is what I got:

Traceback (most recent call last):
  File "client.py", line 90, in callback
    type, data = self.msg.receive()
  File "TcpMsg.py", line 19, in receive
    hdr = self.__socket.recv( struct.calcsize(FORMAT) )
  File "<string>", line 1, in recv
socket.error: (10035, 'The socket operation could not complete without
blocking')

callback is SLOT to QSocketNotifier (for those who know PyQt...)
TpcMsg.py is as follows:
01: import struct
02:
03: FORMAT = '!BL' # short - message type, long message length
04:
05: class TcpMsg:
06:     def __init__( self, socket ):
07:        self.__socket = socket
08:
09:     def send( self, type, message = '_' ):
10:         if len(message) == 0:
11:             print 'len(message) must be > 0'
12:             message = '_'
13:         hdr = struct.pack( FORMAT, type, len(message) )
14:         self.__socket.send( hdr )
15:         self.__socket.send( message )
16:
17:     def receive( self ):
18:         self.__socket.setblocking( 1 )
19:         hdr = self.__socket.recv( struct.calcsize(FORMAT) )
20:         if hdr == '':
21:             return None, None
22:         type, length = struct.unpack( FORMAT, hdr )
23:         print 'r2', len(hdr), type, length
24:         self.__socket.setblocking( 1 )
25:         message = self.__socket.recv( length )
26:         return type, message
27:
28:     def close( self ):
29:         self.__socket.close()

the socket passed to __init__ was by default blocking and even when I forced
it bloking in lines 18 & 24 I still got error 10035... why? any idea?

Pete





More information about the Python-list mailing list