Re: socket programming

Discussion in 'Python' started by Josh Close, Sep 15, 2004.

  1. Josh Close

    Josh Close Guest

    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 <> 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
    >
     
    Josh Close, Sep 15, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,942
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    996
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    571
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    687
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    734
Loading...

Share This Page