Sockets (not WebSockets)

Hi all,

It’s been a while since I asked anything here. My use-case is usually pretty straightforward.

However I have a requirement that has me scratching my head.

I have a collection of machines that send XML as plain text over raw TCP sockets (not Websockets or HTTP). There is a request-response interface for them, which is easy enough. But there is also an event listener mode where I can pass an IP and port number, and the machine makes a persistent callback to that IP and port. There is no security, no encryption, no complexity at all.

When an event fires, the server sends plain-text to the connected socket. I have a POC implementation in a standalone socketserver setup. The event listener requires a separate socket per machine so whatever I come up with, I’ll need to be able to add instances (24 at current count) that feed into the same nameko command(s)

What I am struggling with, is how to build a bridge to Nameko. Any advice?

I’ve found and will be using that for inspiration (I need the message payload in the called method).

Many thanks in advance,


Socket programming is new to me and in my naiveté I thought I needed to spawn a new socket for every remote machine, and in my testing using NetCat that is indeed what I had to do.

I have since done the research and found that the SocketServer (or Eventlet) implementations will allow me to do what I need without having to manage a pool of dedicated sockets.

I think I’ll be able to implement what I need using the sample I posted previously, and a shared queue.

For completeness, what I ended up doing was modifying the sample posted previously to have the message payload back to the registered method. It was a rather elegant solution in the end, so many thanks to @mattbennett for posting that 4 years ago :slightly_smiling_face:

1 Like