服务器端如何在收到客户端消息后,回复消息给客户端

在建立了连接之后,Client端给server端发送了“Nice to meet you!”;希望server端在收到后给client端回复“Nice to meet you too!”,我这里不晓得怎样让server端去回复,哪位高手给指点一下!

# server端

use IO::Socket::INET;
$sock = IO::Socket::INET->new(LocalAddr=>'127.0.0.1',
LocalPort=>8080,
Proto=>'tcp',
Listen=>3,
Reuse=>1) or die "Creat Server ERROR!\n";
warn "Starting server on port8080\n";
$sock_2 = $sock->accept();
while($data=<$sock_2>{
print $data;
}
close $sock;

#client端

use IO::Socket;
$socket=IO::Socket::INET->new(
              PeerAddr=>'127.0.0.1',
              PeerPort=>8080,
              Proto=>"tcp",
              Type=>SOCK_STREAM)
or die "Couldn't connect to 8080@\n";
print $socket "Nice to meet you!\n";

while($answer=<$socket>{
print $data;
}
close($socket);