in reply to Re^3: TCP Socket and Serial Port
in thread TCP Socket and Serial Port

The µC send a Command back, which is sendet to all clients. all clients know what to do with this information.

my problem are not the clients itself as much more: how to communicate correctly between the main thread, the tcp thread and the serial port (=serial thread in my test-case).

regards

Replies are listed 'Best First'.
Re^5: TCP Socket and Serial Port
by BrowserUk (Patriarch) on Jan 12, 2012 at 02:17 UTC

    In a nutshell, use a single thread for communicating with your serial port. Set up two Thread::Queues: one for inbound commands; one for outbound responses.

    When one of your clients sends a command, post it to the inbound queue.

    Have your another thread monitor the outbound queue and forward a copy of each thing it dequeues to every connected client.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?