Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Problem with Socket Programming Perl Script

by Anonyrnous Monk (Hermit)
on Jan 24, 2011 at 10:58 UTC ( [id://883905]=note: print w/replies, xml ) Need Help??


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

tcp        0      0 192.168.0.34:4500           0.0.0.0:*                   LISTEN      22948/nco_objserv

As you've confirmed yourself, the socket/port is already in use by another process, which is why you get the "Address already in use" error.  You need to kill that process if you want to start another one listening on the same port.

The Reuse => 1 option only means that the socket is immediately being freed for reuse when the process exists, not that you can have several processes listening on the same socket (in case that's what you thought).

(I'm a little confused as to what exactly you're trying to do. Your first post looked like you wanted to connect to an existing service. Now it seems you want to write one yourself, but there's already nco_objserv listening on that port...(?))

Replies are listed 'Best First'.
Re^4: Problem with Socket Programming Perl Script
by tyingst (Initiate) on Feb 10, 2016 at 19:44 UTC
    I'm confused by "The Reuse => 1 option only means that the socket is immediately being freed for reuse when the process exists" Do you mean "when the process exits"?
Re^4: Problem with Socket Programming Perl Script
by ashok.g (Beadle) on Jan 24, 2011 at 11:07 UTC
    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?

      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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://883905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found