1
--|proxy|--|mux|--|demux|--|proxy|-- -- -- -- machineA satellite link machineB
172.16.1.224 172.16.1.218Perl客戶機/服務器套接字
問候,
我有安裝如上述。我正在嘗試創建'mux'。基本上,它從代理讀取流量,並將其拆分爲4條線路進行傳輸。 'demux'讀取4條線路並將流量轉發給代理。
我在Perl中有一個基本的客戶端/服務器設置。但我不知道如何從代理獲取流量到'mux'?
這裏是我的代碼:
server.pl - 運行在172.16.1.218
use IO::Socket;
$| = 1;
$socket = new IO::Socket::INET (
LocalHost => '172.16.1.218',
LocalPort => '5000',
Proto => 'tcp',
Listen => 5,
Reuse => 1
);
die "Coudn't open socket" unless $socket;
print "\nTCPServer Waiting for client on port 5000";
while(1)
{
$client_socket = "";
$client_socket = $socket->accept();
$peer_address = $client_socket->peerhost();
$peer_port = $client_socket->peerport();
#print "\n I got a connection from ($peer_address , $peer_port) ";
while (1){
$send_data = <STDIN>;
$client_socket->send($send_data);
$client_socket->recv($recieved_data,10);
print $recieved_data;#."\n";
#$client_socket->autoflush();
}
}
和:
client.pl
use IO::Socket;
$socket = new IO::Socket::INET (
PeerAddr => '172.16.1.224',
PeerPort => 5000,
Proto => 'tcp',
)
or die "Couldn't connect to Server\n";
while (1) {
$socket->recv($recv_data,10);
print $recv_data."\n";
$send_data = <STDIN>;
$socket->send($send_data);
}
我只是有點卡住了將不勝感激任何評論。
提前許多感謝,
嘿,非常感謝您的洞察力。 – Eamorr
很好回答@Francisco R. –
@Francisco R,請看看這個以及: http://stackoverflow.com/questions/15891134/client-server-2-way-communication-unsuccessful-perl?answertab=票#tab-top。 非常感謝:) –