Re: Subclassing socket

2006-01-14 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Steve, > > To your question of why you'd ever receive value: > > This is very common in any network programming. If you send a packet > of data that has a header and payload, and the header contains the > length (N) of the payload, then at some point you have to receiv

Re: Subclassing socket

2006-01-13 Thread Paul Rubin
[EMAIL PROTECTED] writes: > I would like to > create a subclass of socket that fixes the problem. The socket module is in a messy state right now and subclassing sockets doesn't work for implementation-specific reasons besides the issue you described. Take a look at socket.py to see the situation

Re: Subclassing socket

2006-01-13 Thread groups . 20 . thebriguy
I don't think this is true in all cases - for example, if the protocol is UDP, and the packet size is less than the MTU size. Although, I could be wrong - I've always thought that to be the case. I knew someone would have your response, that's why I earlier said I didn't want to argue that. :-)

Re: Subclassing socket

2006-01-13 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > To your question of why you'd ever [recv(0)]. > > This is very common in any network programming. If you send a packet > of data that has a header and payload, and the header contains the > length (N) of the payload, then at some point you have to receive N > bytes. If

Re: Subclassing socket

2006-01-13 Thread groups . 20 . thebriguy
Correction to my last post: It should say: "To your question of why you'd ever recv(0):" -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing socket

2006-01-13 Thread groups . 20 . thebriguy
Steve, To your question of why you'd ever receive value: This is very common in any network programming. If you send a packet of data that has a header and payload, and the header contains the length (N) of the payload, then at some point you have to receive N bytes. If N is zero, then you rece

Re: Subclassing socket

2005-12-21 Thread Steve Holden
[EMAIL PROTECTED] wrote: > socket objects have a little quirk. If you try to receive 0 bytes on a > blocking socket, they block. That is, if I call recv(0), it blocks > (until some data arrives). > Well, arguably you should just try to stop receiving zero bytes. Why on earth is your application

Re: Subclassing socket

2005-12-21 Thread groups . 20 . thebriguy
More simple way? What's that? -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclassing socket

2005-12-20 Thread Maksim Kasimov
you have to agregate socket and the object must have "fileno" method, thats gives a possibility to use instanses of your class with "select.select" function class mySocket: def __init__(self, ...): self.__socket = None ... def fileno(self): return self.__s

Re: Subclassing socket

2005-12-20 Thread Pelmen
imho: class new_socket(socket): def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None) socket.__init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None) def accept( self ): conn, addr = socket.accept() return ( new_socket(_sock=conn), add

Subclassing socket

2005-12-20 Thread groups . 20 . thebriguy
socket objects have a little quirk. If you try to receive 0 bytes on a blocking socket, they block. That is, if I call recv(0), it blocks (until some data arrives). I think that's wrong, but I don't want to argue that. I would like to create a subclass of socket that fixes the problem. Ideally