Я добавил простой сценарий Perl-сервера для сокетов под Cygwin Xinetd, чтобы отобразить ввод клиента, но вместо этого он читается пустым
535
Alan Ma
Я установил Cygwin x7 версии 1.7.33 на мой компьютер с Windows XP x64.
Я добавил новый сервис в /etc/xinetd.d/ccapi.
$ cat ccapi-stream service ccapi { id = ccapi-stream disable = no socket_type = stream protocol = tcp wait = no user = alma server = /cygdrive/c/ccintegration/scripts/cygwin/server_xinet.exe port = 49300 }
Я следовал xinetd-README, чтобы установить xinetd, и запустил его:
cygrunsrv -I xinetd -d "CYGWIN xinetd" -p /usr/sbin/xinetd -a "-stayalive -dontfork" -y tcpip -u alma -w xxx cygrunsrv -S xinetd
Команда " ps -ef" показывает, что xinetd запущен.
Server_xinet.exe - это скомпилированный Perl-скрипт ActiveState. Это повторяет то, что он получает от клиента:
... open($localLog ">> local.log"); $rdata = <STDIN>; chomp($rdata); print $localLog " Data Received at $d $t: <$rdata>\n"; # so I know xinetd loads this exe close $localLog; # write response data to the connected client print STDOUT "You said: $rdata\n"; exit;
Клиентский Perl-скрипт просто отправляет строку на порт 49300.
$HOST = "127.0.0.1"; # also tried using hostname "HOST.xxx.com"; $PORT = "49300"; $data = "@ARGV"; $socket = IO::Socket::INET->new( PeerAddr => "$HOST", PeerPort => "$PORT", Proto => "tcp", ); die "Could not connect to $HOST:$PORT : $@\n" unless $socket; print $socket "$data\n"; $socket->flush(); $answer = <$socket>; print "Echo from server: <$answer>\n"; close($socket);
Я запустил этот клиентский скрипт на той же машине, и он ничего не получает от сервера
$ perl simpleClient.pl "This is it:" Echo from server: <>
Я проверил local.log и нашел там новую запись:
Data Received at 2015mar12 10:11:39: <>
Это означает, что cygwin xinetd запускает server_xinet.exe.
Проблема в том, что сервер ничего не читает, <STDIN>и что бы он ни писал <STDOUT>, клиент не получил его.
Я перенес это с Unix-машины, и там все работает нормально.
В чем проблема здесь, в Cygwin?
Спасибо за любую помощь, которую вы можете предоставить.
1 ответ на вопрос
0
Alma56
I finally got my client/server talking to each other. I decided to use cygwin perl to run both the server and client and it works. Instead of /cygdrive/c/ccintegration/scripts/cygwin/server_xinet.exe (compiled using ActiveState PDK) in /etc/xinetd.d/ccapi-stream, I replaced it with /cygdrive/c/ccintegration/scripts/cygwin/server_xinet.pl Then use '#!/usr/bin/perl' as the first line in both server_xinet.pl and simpleClient.pl.
./simpleClient.pl "This is working" Echo from server: