in reply to Networking with IO::Socket

Layer-4 (ie. the Transport Layer) of the IP stack doesn't work that way.

You can NOT have two services listening on the same protocol/port at the same time, period.

Switching your solution to use the opposite protocol (UDP:2000 vs. TCP:2000) will work fine, but UDP is session-less (which doesn't appear what you want).

Either change your protocol or port, or change the existing service to listen on a different protocol/port.

There is no other way around this, unless you wrap the other service with your script, and have it decipher what traffic is meant for you, or the wrapped service (and if it's for the wrapped service, you need to redirect the traffic along, effectively becoming a filter). This is just the way this portion of the network communication stack works.

-stevieb

Replies are listed 'Best First'.
Re^2: Networking with IO::Socket
by NetWallah (Canon) on Nov 30, 2015 at 01:59 UTC
    You can NOT have two services listening on the same protocol/port at the same time, period.
    There is a small loophole to that - the actual restriction is:
    You can NOT have two services listening on the same protocol/port at the same time at the same IP address.

    So - one possible workaround would be to listen ad different IP addresses, forwarding from one to the other.

    There is a discussion of somewhat less clunky solutions, mirroring traffic from one port to another at:
    http://stackoverflow.com/questions/7247668/duplicate-tcp-traffic-with-a-proxy.

            Our business is run on trust. We trust you will pay in advance.

      D'oh! Very, very good point :) I'm ashamed I missed it. Good job pointing it out.