[Tutor] sockets

Linus Nordström linusno at gmail.com
Tue Jun 19 01:19:45 CEST 2007


gusse i use this thread as my own little help thread.. :)

im having problem whit recv. It will not break the loop if ther are
nothing more to recive. It dose recv all tit should, but then it go
another round in the loop and get stuck on recv, as far as print
debugging has showed,  Dont realy know waht ells information i could
write sown to make my problem anny clrearer, so ask if anythin is
unclear :)

And on another note, is there a way to use the self. less, it might be
just me but it looks rather ugly :)

def recive(self):
         all_data = []
         while 1:
             self.buf = self.s.recv(4096)
             if not self.buf: break
             all_data.append(self.buf)
         return all_data


On 6/18/07, Linus Nordström <linus at linusnordstrom.com> wrote:
> Hello
> I'm trying to rewrite a chat-program i did in school this spring in
> python, the school program was in java. All this to leran python.
>
> Anyway. I m trying to send a message using udp to a server that
> conntains the message 3 0 0 0, it has to be in network byte order and
> unsigned. I have tried to send it like a string "3000" but get an
> error message from the server saying that it did recive 4 bytes, but
> that it was an unknown message
>
> So what i am wondering is if there are anny special byte arrays, or
> some thing i should use. or if there are anny other way than to send
> the message than a string.
>


More information about the Tutor mailing list