perl - Piping to running socat process, But how is this done? -
i have little problem have following situation.
i programmed server tool works. no tried test perl. therefore wrote startscript starting processes need testing, , seperate test script. problem following: have start socat prog before server started in start script. how can connect socat process inputs test script? possible?
ok sorry confusing description try again: have 2 files: 1 starts processes on server , socat process writing data server process. start other necessary processes here not important problem. second file should write socat process sending server. how can connect running socat process (the process has started before server process started. reason server can connect socat)?
short: wanna connect or pipe socat process , not server because server connected socat?
i'm using unix system.
something this: http://www.thegeekstuff.com/2010/07/perl-tcp-udp-socket-programming/
#!/usr/bin/perl #tcpclient.pl use io::socket::inet; # flush after every write $| = 1; ($socket,$client_socket); # creating object interface of io::socket::inet modules internally creates # socket, binds , connects tcp server running on specific port. $socket = new io::socket::inet ( peerhost => '127.0.0.1', peerport => '5000', proto => 'tcp', ) or die "error in socket creation : $!\n"; print "tcp connection success.\n"; # read socket data sent server. $data = <$socket>; # can read socket through recv() in io::socket::inet # $socket->recv($data,1024); print "received server : $data\n"; # write on socket server. $data = "data client"; print $socket "$data\n"; # can send data through io::socket::inet module, # $socket->send($data); sleep (10); $socket->close();
Comments
Post a Comment