On Mon, 12 May 2008 09:19:48 -0700 (PDT), petr.poupa@gmai l.com wrote:
I'm not sure what you want to happen, so I can't write it for you. I
suggest you start with Twisted instead of the socket module, though,
as Twisted provides a higher-level interface to network programming.
You can find some introductory documentation about writing clients here:
Jean-Paul
>
[snip]
>
>ok thanks, but I am true greenhorn, so you think that the best way is
>write new script?
>Could you send me code if it isnt long, becase I have no idea and
>unfortunatel y time as well.
>
[snip]
>>
>>
>You cannot reconnect a socket. You need to create a new one for each
>connection. It's also almost certainly the case that the way you are
>receiving data is incorrect. There is no guarantee that you will get
>2048 bytes from socket.recv(204 8). It isn't even guaranteed that all
>the bytes written to the socket by the peer will be returned by such
>a call. Instead, you need a framing protocol to determine when all
>data has been received. For example, you might length prefix the
>data, or you might insert a delimiter (or a terminator) at the end. Or
>if there is exactly one message to receive, then you should just read
>until the recv call returns '', indicating EOF.
>>
>Jean-Paul
>Where is the mistake? I dont know.
>You cannot reconnect a socket. You need to create a new one for each
>connection. It's also almost certainly the case that the way you are
>receiving data is incorrect. There is no guarantee that you will get
>2048 bytes from socket.recv(204 8). It isn't even guaranteed that all
>the bytes written to the socket by the peer will be returned by such
>a call. Instead, you need a framing protocol to determine when all
>data has been received. For example, you might length prefix the
>data, or you might insert a delimiter (or a terminator) at the end. Or
>if there is exactly one message to receive, then you should just read
>until the recv call returns '', indicating EOF.
>>
>Jean-Paul
>ok thanks, but I am true greenhorn, so you think that the best way is
>write new script?
>Could you send me code if it isnt long, becase I have no idea and
>unfortunatel y time as well.
>
suggest you start with Twisted instead of the socket module, though,
as Twisted provides a higher-level interface to network programming.
You can find some introductory documentation about writing clients here:
Jean-Paul
Comment