Are you writing a client or a server? BTW, the variable $sockin above is not initialised.
Below is a simple client that connects to the echo server on port 7. Instead of using IO::Socket, you could write the client at a lower level using the socket/inet_aton/sockaddr_in/connect/close functions. See perldoc perlipc for more information. If you want to write a server instead, please let us know.
use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => 7, # echo server Proto => 'tcp', Type => SOCK_STREAM ); die "Could not create socket: $!\n" unless $sock; print $sock "Hello there!\n"; my $answer = <$sock>; print "answer: $answer\n"; close($sock);
In reply to Re: Perl socket handling problem
by eyepopslikeamosquito
in thread Perl socket handling problem
by HumanProgrammer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |