> 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?

Can you tell us exactly what you have tried to produce this error. Did you
first start the server and verify that it was started and in bound to a
listening port (you can check with netstat)? and then try to connect with
the client.

 
> my Server is
> 
> #!/usr/bin/perl
> #use strict;
> use IO::Socket;
> use Socket;
> use Carp;

I don't think you need IO::Socket since it looks like you are using all
native socket calls.

> 
> #make the socket
> 
> $server_port ='2354';
> socket(SERVER,PF_INET,SOCK_STREAM,getprotobyname('tcp'));

how about some error checking here 

> 
> 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";
What do you get from the above output? 


> 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);
> 
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to