TCP Listening to Port

I have a device - a closed device - that sends data to an IP address at a specific port. I am working on making a smarter controller using the Raspberry Pi 2. Although this is on the Pi 2 it is somehting I have tested on Computer to Computer. All works well if I can have a Server - Client as in the Internet Communications example. However on the real device that sends data I cannot setup a Server-Client connection as the other side is a closed device where I cannot add either a Server or Client app.

My question is what and how do I enable listening on a TCP:Port so I can then act on data being sent-received?

I have attempted multiple combinations of the Client side examples without success such as:

mCurrentSocket = 0 SCG_TCPSocket(mCurrentSocket).Port = IPPort SCG_TCPSocket(mCurrentSocket).Address = TCPIP SCG_TCPSocket(mCurrentSocket).Connect mCurrentSocket = mCurrentSocket + 1

Where TCPIP = a string containg a valid IPv4 address
Where IPPort = an integer of the port I need to listen for data on

When data is sent from the other side to the Port nothing comes in the ‘DataAvailable’ Event Handler

I can ping the other device. Any thoughts?

Use the Listen method… Not Connect.

Fwiw, if this closed device closes the connection every time, you might still want to use a ServerSocket on the raspberry pi. That way you don’t need to handle tearing down and starting up a new socket every time.

That worked espeically the Fwiw - that was spot on. I have some debugging to do to convert the data but it is being received - Thanks

Once completed the next step will be to move this to a Console app. How do I move a multiple port TCPSocket to a Console application? In Desktop I drop a TCPSocket onto the Window and then add Members. I can create a TCPSocket but see no way to add Members when Listen creates those sockets

You’ll need to create a property in the app class (or a module) to store your socket(s).