Re: How to read and write the same socket in different threads?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean-Paul Calderone

    Re: How to read and write the same socket in different threads?

    On Sat, 23 Aug 2008 01:47:23 +0800, Leo Jay <python.leojay@ gmail.comwrote:
    >I'd like to read and write the same socket in different threads.
    >one thread is only used to read from the socket, and the other is only
    >used to write to the socket.
    >But I always get a 10022 'Invalid argument' exception. Anyone knows why?
    >
    >I'm using windows xp.
    >
    >my source code is here:
    >http://pastebin.com/m23e633a2
    >
    You're connecting and accepting with the same socket. That's not a very
    good thing to do. You're not even reading and writing on the same socket,
    since you're writing to the socket which you get from accept (if the code
    could get that far).

    What are you trying to do? Why are you connecting and accepting? Why do
    you need two threads?

    Have you seen Twisted? http://twistedmatrix.com/

    Jean-Paul
Working...