experts pls help.
Hello,If this is a question for a different group,could someone please redirect me.
I am kind of beginner with socket prog .I am just trying to connect a server and a
client.I am unable to receive data from the client.
my output is
port :2354
addr = 2
127.0.0.1
cant receive Transport endpoint is not connected
What does "Transport endpoint is not connected" mean?
my Server is
#!/usr/bin/perl
#use strict;
use IO::Socket;
use Socket;
use Carp;
#make the socket
$server_port ='2354';
socket(SERVER,PF_INET,SOCK_STREAM,getprotobyname('tcp'));
setsockopt(SERVER,SOL_SOCKET,SO_REUSEADDR,1);
print "port :$server_port\n";
#build up my socket address
my $my_addr =sockaddr_in($server_port,INADDR_ANY);
print "addr =$my_addr\n";
bind(SERVER,$my_addr)
or die "Could'nt bind to port $server_port:$!\n";
#establish a queue for incoming connections
listen(SERVER,SOMAXCONN)
or die "Could'nt listen on port $server_port:$!\n";
#accept and process connections
while($client_address = accept(CLIENT,SERVER)) {
($port,$packed_ip)=sockaddr_in($client_address);
$dotted_quad = inet_ntoa($packed_ip);
print $dotted_quad."\n";
$len =11;
recv(SERVER,$data_read,$len,$flags)
or die "cant receive $!\n";
#$response =<SERVER>;
print "response: $data_read"."\n";
print "client arrives\n";
}
=====================================
The client is
#!/usr/bin/perl
use Socket;
socket(TO_SERVER,PF_INET,SOCK_STREAM, getprotobyname('tcp'));
$remote_host ='127.0.0.1';
$remote_port ='2354';
$internet_addr = inet_aton($remote_host)
or die "could'nt convert $remote_host into an internet address\n";
$paddr = sockaddr_in($remote_port,$internet_addr);
# connect
connect(TO_SERVER,$paddr)
or die "could'nt connect to $remote_host:$remote_port\n";
#print TO_SERVER"\n";
#print TO_SERVER "why no call\n";
send(TO_SERVER,"why no call",$flags,$paddr);
shutdown(TO_SERVER,1);
---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site