0
I installed a x32 version 1.7.33 of Cygwin on my x64 Windows7 machine.
I added a new service under /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
}
I followed the xinetd-README to install xinetd and started it:
cygrunsrv -I xinetd -d "CYGWIN xinetd" -p /usr/sbin/xinetd -a "-stayalive -dontfork" -y tcpip -u alma -w xxx
cygrunsrv -S xinetd
Command "ps -ef
" shows xinetd is running.
The server_xinet.exe is a compiled ActiveState perl script. It echoes what it receives from the client:
...
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;
The client perl script just sends a string to port 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);
I ran this client script on the same machine and it receives nothing from the server
$ perl simpleClient.pl "This is it:"
Echo from server: <>
I checked the local.log and finds a new entry in there:
Data Received at 2015mar12 10:11:39: <>
This means cygwin xinetd launches server_xinet.exe.
The problem is that the server reads nothing from <STDIN>
and whatever it writes to
<STDOUT>
, the client did not receive it.
I ported this from a Unix machine and it works fine there.
What is the problem here in Cygwin?
Thanks for any help you can provide.