netcat command is not working in bidirectional mode

0

I am using netcat in Linux to send and receive data (using udp protocol) from a serial port to another device through the network. The command is :

nc -u 192.168.10.12 < /dev/ttyUSB0 > /dev/ttyUSB0 

The USB I am using is a USB to serial 485 converter and I am noticing that the receiver light is not blinking at all while the transmit light is blinking.

I checked whether the messages are been sent and received through the network using tcpdump and I could clearly see that it is transferring the data between my machine and the device machine! I am now thinking it might be netcat problem any ideas ?

user573014

Posted 2013-11-27T07:24:51.100

Reputation: 131

Try using TCP. UDP datagrams can get lost or blocked by a firewall without any error being reported. – wingedsubmariner – 2013-11-27T17:23:36.213

I tried that as well, same problem – user573014 – 2013-11-27T18:32:02.133

Answers

0

Just throwing this out there..

But control-d can signal end of file, and perhaps your input streams include this character. That would shut down that input stream, while the other might continue working.

While I don't know what happened in your particular situation, I know you can test this via nc on the command line:

#create a server
nc -v -v -l -p 9000      #yes, I was testing xdebug...


-------- in a different terminal:

#create a client
nc localhost 9000

Type something in both. Hit Ctrl-D in one. Now stuff you type in that terminal won't show up, but the stuff you type in the other terminal will still show up.

Caught me by surprise. I thought it had some kind of buffer issue or was half duplex. Found your question before finding the answer.

Oh, and to make sure it doesn't behave this way:

stty eof undef

Gerard ONeill

Posted 2013-11-27T07:24:51.100

Reputation: 101