0

I have a specific service that sends data on port 5555. I need to open socket on shell unix to listen on this port and print output on shell. Service is deployed as docker container. So, I run container binding port 5555:5555.

I tried to run nc -l localhost 5555 on my host but it not work. I tried to open container shell and run netstat. This is the output:

# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
tcp        0      0 localhost:epmd          localhost:49664         ESTABLISHED 
tcp        0      0 localhost:49664         localhost:epmd          ESTABLISHED 
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  3      [ ]         STREAM     CONNECTED      98194 
unix  3      [ ]         STREAM     CONNECTED      98193 
unix  3      [ ]         STREAM     CONNECTED      99655

I'm sure that service sends data but I cannot receve. Can you help me? Thanks

5
  • Do you need to listen on TCP or UDP? Is the container binding done on localhost address or on an actual IP on an (bridge)-interface? Commented Jun 15, 2022 at 8:51
  • I need to open on UDP. Container is run on remote host using -p 5555:5555 in docker run comand. I prefer to listen from remote host but to be able to listen from localhost can be a first good result. Can nc -l localhost 5555 used to listen from Unix socket? Thanks Commented Jun 15, 2022 at 8:54
  • 1
    You need to specify -u to listen on UDP sockets, -U for unix domain sockets. Commented Jun 15, 2022 at 9:06
  • Thanks for the help. Now its work from my container shell. I used ``` nc -u -l localhost -p 5555. I add -u and -p option. Now, It does not work from remote host. Using nc -u -l remoteIP -p 5555``` I dont' receve anything. Reading documentation is not necessary set particulary option to listen from remote host. I'm able to connect to remoteIP. Commented Jun 15, 2022 at 9:45
  • You would specify nc -l -u IP PORT to listen and use udp, then bind (locally) to the IP on port PORT. When you want to receive data from a remote host, IP cannot be localhost but must be the address of an actually connected interface. Commented Jun 15, 2022 at 11:05

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.