I guess no one here could help me out. Luckily, the PerlMonks were able to do so.
If you are interested read on.
Turns out the reason that the sockets weren't working together from different boxes/IP's was because of the security features of the boxes. I couldn't even telnet into the ports I was running with the server socket so that gave us a pretty good idea.
Also found out some good things about creating sockets efficiently. I'm posting the code in case anyone is interested. One of the key points to the server socket was to not bind the socket to a specific IP, for two reasons. One, if the IP I bind to is invalid, I'm screwed and the damn thing won't work. Two, by not binding to one specific IP, the socket will listen on all possible points of entry at the port that is assigned(you have to assign a port).
Anyway, thought that was interesting. Here's the code.
First for the Server Socket.
Code:
#!/usr/bin/perl
use IO::Socket;
$sock = new IO::Socket::INET( LocalPort => 1200,
Proto => 'tcp',
Listen => 10,
Reuse => 1,
Type => SOCK_STREAM );
die $@ unless $sock;
print "Listening for incoming connections...\n";
while ( $new_sock = $sock->accept() ) {
$clnt = $sock->sockhost();
print "New connection from $clnt...\n";
while ( $buf = <$new_sock> ) {
print $buf;
}
print "Client disconnected...\n";
}
close( $sock );
Now for the client socket.
Code:
#!/usr/bin/perl
use IO::Socket;
$sock = new IO::Socket::INET( PeerAddr => 'localhost',
PeerPort => 1200,
Proto => 'tcp' );
die "Socket could not be created: $!\n" unless $sock;
print "Input Message: ";
$msg = <STDIN>;
while ( $msg !~ m/^\n$/ ) {
$inp = $msg;
undef( $msg );
print $sock "MSG: $inp";
$sock->flush();
print "Input Message: ";
$msg = <STDIN>;
}
close( $sock );
Right now the client is designed to reside on the same host as the server...try 'em out if you like.
Thanks for listening.
