sarf13 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Socket programming problem
by NetWallah (Canon) on Nov 30, 2013 at 23:57 UTC | |
by sarf13 (Beadle) on Dec 03, 2013 at 19:02 UTC | |
by NetWallah (Canon) on Dec 05, 2013 at 17:14 UTC | |
|
Re: Perl Socket programming problem
by kcott (Archbishop) on Dec 01, 2013 at 00:38 UTC | |
|
Re: Perl Socket programming problem
by Laurent_R (Canon) on Nov 30, 2013 at 23:59 UTC | |
by sarf13 (Beadle) on Dec 01, 2013 at 06:28 UTC | |
by Laurent_R (Canon) on Dec 01, 2013 at 09:57 UTC |