How does netcat manage the data it transfers ?

Hi all,

When using netcat to transfer the data over socket, if no connection is established, how long will netcat keep the data; will it discard the "oldest" data ?

Say for example I use "Some Command | netcat -l -p port", the command I use will generate a lot of output constantly, while no connection is established yet, will netcat discard the "oldest" data so after the connect is finally established, I only see the latest data ?

I suspect it should work in this way. If yes how do I set the buffer size ? If no how does it work then ?

Thanks!

Hi qiulang Only thing I somewhere read about netcat is:

If you want transfer file between machines you type
reciever# nc -l p 8000 > /home/user/destination
sender# nc reciever 8000 < /home/user/source
But if somebody else start to send packets to reciever:8000 they will be ignored (cause it is TCP comunucation and session has been established previous)
Maybe it will help you

---------- Post updated at 11:37 AM ---------- Previous update was at 11:27 AM ----------

also found tool called netcat++ socat

Thanks for replying although this was not what I was looking for.

I find from here Netcat: the TCP/IP swiss army saying that "Data from the network connection is always delivered to standard output as efficiently as possible, using large 8K reads and writes."

So I guess 8k is the buffer size and if data is bigger than 8k while connect has not been established, the "oldest" data will be discarded. Can anyone confirm ?

Thanks!