I only took a quick look but I think this is the problem...

1) It looks like your splitter creates a new socket each time it wants to forward a packet. This is extremely wasteful.

2) The splitter doesn't specify what local port to send from so each time you create this new socket it will get a new local port number.

3) Your check is against the sender's (splitter's) source port so, yes, that port number will be constantly changing and you'll get the error you describe.

So the fix is to move the new() method call outside of the loop in your splitter.

Just in case there is some deeper confusion involved in this mistake Also, a bit of a tutorial on some much-misunderstood aspect of TCP/IP is probably in order...

Every UDP packet (or TCP connect) has four address elements associated with it: Source IP address, source port number, destination IP address, and destination port number. When talking about a socket we replace "source" and "destination" with "local" and "remote".

A server usually specifies its local port number and nothing else. The local IP address is determined by the address the client uses to contact the server (having a server specify the local IP address is about the most common TCP/IP programming mistake there is). A client usually specifies the the remote IP address and remote port number and lets the operating system fill in appropriate local IP address (depends on the network interface that will be used to reach the server, determined from the server's IP address) and local port number (pretty much a random port number that is currently not in use).

So you don't want to create a new UDP socket for each packet that you send out. In fact, you can just use one socket for all three purposes in the splitter: receiving packets, sending copies to the first destination, and sending copies to the second destination (this wouldn't work for TCP since each socket has to be connected to a single desination). Just specify the destination address when you send each packet out.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: IO:Socket::NET problem & Counter-Strike by tye
in thread IO:Socket::NET problem & Counter-Strike by Myron DaChump

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.