Shop OBEX P1 Docs P2 Docs Learn Events
Connecting to Two TCP Servers — Parallax Forums

Connecting to Two TCP Servers

VasquesVasques Posts: 1
edited 2014-04-02 18:51 in Accessories
Does anyone have some sample code showing how to open two TCP connections to two different servers and keeps them open?

The servers are sending plain text. I'd like to capture and compare it. Then I'll do something or loop.

Using the TCP Client Demo I found online, I have been able to modify it to open one connection successfully. When I add the second one on a different socket it crashes. I load them both using cognew. It looks like things go bad when I establish the second connection. (I should add that I hacked this together, so I am probably missing something)

Any ideas or thoughts are welcomed.

Comments

  • Mike GMike G Posts: 2,702
    edited 2014-04-02 18:51
    Welcome to the forum.

    I believe the issue not multiple sockets, it's multiple COGs. There's only one SPI bus. Two COGs talking on the bus at the same time will cause a collision.

    Either use one COG and poll the sockets or use a semaphore.

    Also, it's a good idea to post your problematic code.
Sign In or Register to comment.