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

Well, I don't see how it could write to the socket the first time since you don't give a destination address/port. Also, I strongly discourage specifying a local IP address and I don't recommend specifying a local port number. Certainly if you specify a local port number then you should be checking whether the new() fails!

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re2: IO:Socket::NET problem & Counter-Strike

Replies are listed 'Best First'.
Re: (tye)Re2: IO:Socket::NET problem & Counter-Strike
by Myron DaChump (Initiate) on Mar 31, 2001 at 10:10 UTC
    Okay, then I am confused. I am not so sharp, so give me a leg up here. Would you mind actually composing an example socket for me?

    You are of course right about the NEW statment, moving the creation to outside of the loop does run, but when I start the other script to listen on port 50000 it says that the socket is already in use. I am lost boss.

    -Myron DaChump

      Hm, it looks like you somehow change "Peer" to "Local" when you moved those lines. Change "Local" back to "Peer" and try again.

      Update: Note the >>>Tagged<<< parts:

      while ($socket->recv(my $in, 1024) ) { my $sock = IO::Socket::INET->new( Proto => 'udp', >>>Peer<<<Addr =>'127.0.0.1:50000'); print $sock $in; }
      To this....
      my $sock = IO::Socket::INET->new( Proto => 'udp', >>>Local<<<Addr =>'127.0.0.1:50000'); while ($socket->recv(my $in, 1024) ) { print $sock $in; }
      so the code should look like this:
      my $sock = IO::Socket::INET->new( Proto => 'udp', PeerAddr =>'127.0.0.1:50000'); while ($socket->recv(my $in, 1024) ) { print $sock $in; }

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