Connecting to Two TCP Servers
Vasques
Posts: 1
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.
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
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.