Networking Forums

Networking Forums > Computer Networking > Linux Networking > netcat as server, answers client inconsistently

Reply
Thread Tools Display Modes

netcat as server, answers client inconsistently

 
 
david
Guest
Posts: n/a

 
      03-22-2006, 01:25 AM

I'm trying to make netcat behave as a simple server, but directing its
output back to the client is inconsistent.

I'm using the named-pipe/fifo technique I've seen documented. But why
doesn't it work except with "cat", as follows?

while true;do nc -vv -l -p 5555 0< /tmp/backpipe | cat 1>
/tmp/backpipe;done

Only this works. If it receives some text from another machine
(executing e.g., echo TEST | nc <serverIP> 5555 ), it successfully
boomerangs the text back to that client machine. But if I replace
"cat" with anything else (e.g., a tr command to do character
substitutions), nc doesn't manage to send back the processed result
(even though it does get into the backpipe).

If the command is "cat" the nc output is:

[root@CHANG tmp]# while true;do nc -vv -l -p 5555 0< /tmp/backpipe |
cat 1> /tmp/backpipe;done
Listening on any address 5555
Connection from 192.168.3.2:1148
Total received bytes: 5
Total sent bytes: 5
Listening on any address 5555

Otherwise nc sends nothing back:

CHANG tmp]# while true;do nc -vv -l -p 5555 0< /tmp/backpipe | tr TES
tes 1> /tmp/backpipe;done
Listening on any address 5555
Connection from 192.168.3.2:1149
Total received bytes: 5
Total sent bytes: 0
Listening on any address 5555

In both cases the to-be-returned output *does* make it successfully
into the backpipe (a server-local "cat backpipe" shows it). In one
case it is extracted from there and returned to the client by the
original "nc" and in the other not. Why??

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem opening a listening port using netcat ( or other server ) bradphelan Linux Networking 3 10-06-2006 08:04 PM
BT Answers Maciej Broadband 5 01-19-2006 01:29 PM
Re: netcat as an http proxy server William Park Linux Networking 0 07-05-2004 08:40 PM
No Answers, where to go from here? cc Windows Networking 1 10-18-2003 05:38 PM
Using netcat for a small server Thomas Henkel Linux Networking 1 07-25-2003 05:05 PM



1 2 3 4 5 6 7 8 9 10 11