S
Swanand.Kakade
This is the script i am useing as SERVER
# server0.pl
#--------------------
use strict;
use Socket;
# use port 7890 as default
my $host = shift || '10.255.37.164';
my $port = shift || 7890;
my $proto = getprotobyname('tcp');
# create a socket, make it reusable
socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";
# grab a port on this machine
my $paddr = sockaddr_in($port, gethostbyname('proddev'));
#my $paddr = sockaddr_in($port,inet_aton('proddev'));
# bind to a port, then listen
bind(SERVER, $paddr) or die "bind: $!";
listen(SERVER, SOMAXCONN) or die "listen: $!";
print "SERVER started on port $port ";
# accepting a connection
my $client_addr;
while ($client_addr = accept(CLIENT, SERVER))
{
# find out who connected
my ($client_port, $client_ip) = sockaddr_in($client_addr);
my $client_ipnum = inet_ntoa($client_ip);
my $client_host = gethostbyaddr($client_ip, AF_INET);
# print who has connected
print "got a connection from: $client_host","[$client_ipnum] ";
# send them a message, close connection
print CLIENT "Smile from the server";
close CLIENT;
}
When i tries to run this script ...
it shows following error ...
bind: Unknown error at E:\QTP\Perl\server.pl line 21.
Client script that i am using is...
# client1.pl - a simple client
#----------------
use strict;
use Socket;
# initialize host and port
my $host = shift || '10.255.37.164';
my $port = shift || 7890;
my $proto = getprotobyname('tcp');
# get the port address
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);
# create the socket, connect to the port
socket(SOCKET, PF_INET, SOCK_STREAM, $proto)
or die "socket: $!";
connect(SOCKET, $paddr) or die "connect: $!";
my $line;
while ($line = "")
{
print $line;
}
close SOCKET or die "close: $!";
What I want to achieve is here server will sent some message and
client will read and pass this message... to another server for
processing.
Pls can any one tell me what is that error " bind: Unknown error at
E:\QTP\Perl\server.pl line 21. "
What need to do for this?
pls reply as soon as possible u can contact me (e-mail address removed)
# server0.pl
#--------------------
use strict;
use Socket;
# use port 7890 as default
my $host = shift || '10.255.37.164';
my $port = shift || 7890;
my $proto = getprotobyname('tcp');
# create a socket, make it reusable
socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";
# grab a port on this machine
my $paddr = sockaddr_in($port, gethostbyname('proddev'));
#my $paddr = sockaddr_in($port,inet_aton('proddev'));
# bind to a port, then listen
bind(SERVER, $paddr) or die "bind: $!";
listen(SERVER, SOMAXCONN) or die "listen: $!";
print "SERVER started on port $port ";
# accepting a connection
my $client_addr;
while ($client_addr = accept(CLIENT, SERVER))
{
# find out who connected
my ($client_port, $client_ip) = sockaddr_in($client_addr);
my $client_ipnum = inet_ntoa($client_ip);
my $client_host = gethostbyaddr($client_ip, AF_INET);
# print who has connected
print "got a connection from: $client_host","[$client_ipnum] ";
# send them a message, close connection
print CLIENT "Smile from the server";
close CLIENT;
}
When i tries to run this script ...
it shows following error ...
bind: Unknown error at E:\QTP\Perl\server.pl line 21.
Client script that i am using is...
# client1.pl - a simple client
#----------------
use strict;
use Socket;
# initialize host and port
my $host = shift || '10.255.37.164';
my $port = shift || 7890;
my $proto = getprotobyname('tcp');
# get the port address
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);
# create the socket, connect to the port
socket(SOCKET, PF_INET, SOCK_STREAM, $proto)
or die "socket: $!";
connect(SOCKET, $paddr) or die "connect: $!";
my $line;
while ($line = "")
{
print $line;
}
close SOCKET or die "close: $!";
What I want to achieve is here server will sent some message and
client will read and pass this message... to another server for
processing.
Pls can any one tell me what is that error " bind: Unknown error at
E:\QTP\Perl\server.pl line 21. "
What need to do for this?
pls reply as soon as possible u can contact me (e-mail address removed)