> -----Original Message-----
> From: alex chen [mailto:cg@;gddc.com.cn]
> Sent: Sunday, November 03, 2002 6:05 AM
> To: [EMAIL PROTECTED]
> Subject: hi,everyone,help me
> 
> 
> hi,all!
>    today,i have write such a program
> 
> #!usr/local/bin/perl5.6.1
> #middle machine version 1.0
> 
> use IO::Socket;
> 
> $SIG{CHLD} = sub {wait()};
> $main_sock = new IO::Socket::INET(LocalHost =>'192.168.1.2',
>                                   LocalPort => 34561,
>           Listen    => 5,
>           Proto     => 'tcp',
>           Reuse     => 1,
>                                  );
> die "main Socket could not be created.Reason: $!\n" unless 
> ($main_sock);
> while ($new_sock = $main_sock->accept()){
>      $pid = fork();
>   die "Cannot fork : $!" unless defined ($pid);
> if ($pid ==0){
>     while (defined ($buf = <$new_sock>)){
>   print $buf;
>   send_message();}
>   exit(0);
> }
> }
> close ($main_sock);
> 
> sub send_message{
>  $send_sock = new IO::Socket::INET(PeerAddr =>'192.168.1.3',
>                                    PeerPort =>34562,
>            Proto    =>'tcp'
>            );
> die "Socket Could not be created.Reason:$!\n" unless $send_sock;
>   print $send_sock $buf;
>   $send_sock ->flush();
> close ($send_sock);
> }
> 
> the problem is the socket $send_sock could not establish with the host
> 192.168.1.3 while i run this program
> the hos 192.168.1.3 just a simple program to recieve the 
> message from this
> program.
> how to resolve this problem,please help me ,thanks!!! :-)

You bind the server socket $to 192.168.1.2, but your client attempts to
connect to 192.168.1.3

Does the server have two interfaces or is 192.168.1.2 the client's IP? If
the former, then change your client to connect to 1.2. If the latter, change
your server to bind to 1.3 (or leave off LocalHost altogether, to bind to
all interfaces).

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

Reply via email to