Help me out to understand the socket programming.For passing data from one machine to another machine over TCP/IP protocol. What all basic things i have to take care for creating socket script?? Do I have to always run below server script on server end?? Is there any way to run server script remotely?? Is there any way to pass data across the machine running both server and client script at one machine only??
server script
use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '7890', Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $sock; my $new_sock = $sock->accept(); while(<$new_sock>) { print $_; } close($sock);
client script
use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '7890', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; my @val = qw(Hello there! this is socket); print $sock @val; close($sock);
sorry I was not very much cleared my problem above
actually my requirement is simple to pass data from one machine let say M1 (client) to machine M2 (server) in the form of defined binary data set (Binary structure data which define for system to accept).
here my problem is I cannot execute my server script (which I have given above) on machine M2 (server) end. Is there any other way to pass data from M1 (client) to M2 (server) without executing server script
In reply to Perl Socket programming problem by sarf13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |