0

I have an ASCII file, which looks like this:

36,36,0,1
36,36,0,2
...

What I want to do is to send every row of it as one binary TCP segment's payload with NetCat.

To convert the number from file to its binary representation I'm using Perl's print pack("c", <STDIN>); so I can easily convert whole file (number by number). I know also how to send it with cat file | netcat localhost 9999 but this command sends whole content as payload in one segment.

What can I do to send every line of original file (converted to binary) as a new TCP segment?

1 Answer 1

0

OK, so I have found a solution.

To send every n bytes from file as a new TCP segment, the command similar to given below can be used:

for i in `seq 1 $num_of_segments`
  do
  head -c $i file_name | tail -c 1 | netcat localhost 9999
done

Option -c n in head and tail commands tells to pipe first or last n bytes.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .