Re: asynchronous comunication, wxPython and threads.



On Tue, 21 Jun 2005 11:07:35 -0400, Peter Hansen wrote:

>
> Please clarify: what does this mean? "Sending a socket" is not a usual
> way to describe TCP communications. Do you mean your program _opens_ a
> socket (like a phone connection) and _sends_ some data, then waits for
> data to be received from the other end? Or are you (as it almost
> sounds) opening and closing sockets repeatedly for each part of the
> conversation?
>

Sorry for the lack of clarity. I opened the socket once (i don't know if
itit is important to open inside or outside the comunication thread). And
them send "packages" and wait for data.


>
> I think you are using the term "socket" where you should be using
> "packet". A socket is the virtual connection created by TCP. A packet
> is either a single blob of data sent by the TCP code in the operating
> system, or perhaps a single chunk of your own data.
>

Thanks for the vocabulary correction.

> If you are using a single TCP socket to send multiple packets, and you
> are talking about those packets being sent out of order, it's very
> unlikely and there must be another explanation. TCP _is_ reliable, and
> you will not get data out of order unless you do something to screw
> things up, for example by creating a race condition by doing
> multithreaded code incorrectly.
>

I think this is the case (see the post of Toby). I didn't try it out but I
think the problem is that i *do* comunication in both threads.

>
> Some people advise that, but there's really nothing *wrong* with doing
> this in a second thread, and in fact I do similar things all the time
> with no ill effects. While async frameworks _can_ make this easier,
> they could also make it harder (at least for a while) as you adjust your
> brain to the new approach. Furthermore, at least in the case of
> wxPython and Twisted (on Windows) there can be problems integrating the
> two loops. I don't believe the latest Twisted claims to have fully
> solved the problems involved yet, so you might still be required to have
> a second thread for the TCP stuff.
>

Yes, i have read that there is problems yet.

>
> I use a non-blocking socket and select() calls in my thread, and
> communicate with the GUI thread using appropriate Queue objects and
> calls to PostEvent() (or CallAfter()) on the wx side of things. It's
> pretty straightforward, so if you post a small piece of your application
> which reproduces the problem it shouldn't be hard for someone here to
> help you fix it.
>

Thanks. First i would check if the problem is what Toby says.

>
> No more so than using threads, unless your problem is caused by the
> threads themselves (as I suggested above) in which case it might be
> easier to just fix the problem.
>
> -Peter

Thank you very much

Zunbeltz

.



Relevant Pages

  • Re: TCP Blocking sockets
    ... a blocking socket does *not* block until the other side receives ... >> I guess if I don't want to flood a tcp link with data, ... With TCP/IP the receiving system will wait for the packet to ...
    (alt.comp.lang.borland-delphi)
  • Re: C# Raw Socket Issues starting TCP Connections
    ... the TCP stack has no information about what you are doing ... of IP packet and send it along with the data, you can build a SYN packet ... and send it to the TCP server program which is actively listening. ... > read incomming data if I use IOControl and set the socket SIO_RCVALL. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TCPIP Default keep alive question
    ... since last December we have been getting ASOD abends in certain CICS ... Did you mean to alert us to the possibility that the *partner* TCP ... SO_KEEPALIVE socket option and do not override the interval using the ... TCP keepalive probes end TCP connections after a period of inactivity. ...
    (bit.listserv.ibm-main)
  • Re: TCPIP Default keep alive question
    ... Did you mean to alert us to the possibility that the *partner* TCP application ... SO_KEEPALIVE socket option and do not override the interval using the ... TCP keepalive probes end TCP connections after a period of inactivity. ... If the TCP_KEEPALIVE socket option is not used to specify the probe ...
    (bit.listserv.ibm-main)
  • Re: Socket stuck with puts over ADSL line
    ... gets stuck with the puts command within the filevent writeable ... Is the socket configured as -blocking 1? ... local buffer would fill rapidly, ... buffered portion across the WAN as its own TCP packet, ...
    (comp.lang.tcl)