[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
[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
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. :-)
[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
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
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
[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
More simple way? What's that?
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
11 matches
Mail list logo