Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: socket programming

Reply
Thread Tools

Re: socket programming

 
 
Josh Close
Guest
Posts: n/a
 
      09-15-2004
Use asynchore/asynchat modules. They will do all that stuff for you.

http://docs.python.org/lib/module-asyncore.html
http://docs.python.org/lib/module-asynchat.html

-Josh


On Thu, 16 Sep 2004 02:49:13 +1000, Ajay <(E-Mail Removed)> wrote:
> hi!
>
> on my client side, i have a socket that sends and then receives
> the code is
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect((PDA_ADDRESS, PDA_PORT))
> s.send("persona=")
> s.send(persona)
> s.send("\n")
> str = s.recv(1024)
> data=""
> while len(str) != 0:
> data += str
> str = s.recv(1024)
> print data
>
> on my server side i create the serversocket, listen, get the client socket
> and the client socket receives the data as follows
> (clientsocket, address) = serversocket.accept()
> str = clientsocket.recv(256)
> data=""
> while len(str) != 0:
> data += str
> str = clientsocket.recv(256)
>
> the problem is when my client finished sending and waits to receive, on the
> server side, it still stays in the while loop waiting to receive more data.
>
> how do i stop that?
>
> thanks
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments