in reply to Re^3: Problem with Socket Programming Perl Script
in thread Problem with Socket Programming Perl Script

See,
nco_objserv is the process which send the data via port 4500.
So, I need to catch that data. If I kill that process then I won't have any data on that port.
In this scenario how can I achieve this functionality?

Replies are listed 'Best First'.
Re^5: Problem with Socket Programming Perl Script
by Anonyrnous Monk (Hermit) on Jan 24, 2011 at 11:12 UTC

    You seem to have it backwards. nco_objserv is listening on that port (see "LISTEN" in netstat output).  That means it won't send any data unless you connect to it as a client. Which is what your first attempt looked like... So, modify that initial code to just don't do accept, but rather simply read from the socket.

      Also, I have
      tcp        0      0 192.168.0.34:4500           192.168.0.34:32996          ESTABLISHED 22948/nco_objserv Here, for the port 4500 I have both LISTEN and ESTABLISHED.Can't I retrieve data now?
        Can't I retrieve data now?

        Unlikely, PEBKAC related

        This just means that nco_objserv is having open ("ESTABLISHED") connections to other processes (nco_p_syslog and nco_p_mttrapd presumably, judging by your previous netstat output).

        As servers typically allow to have connections to multiple clients at the same time, you can likely still connect to it.