Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send a byte (or bytes) to test a socket listening in my application? [closed]

How can I send a byte (or bytes) to test a TCP socket that's listening on a port in my application? My application receives a single byte that tells it what to do. Some operations will receive additional bytes to further instruct it.

I tried using Telnet already, but when I input the int value, it seems to send the int (4 bytes).

I just need to send a single byte (8 bits), instead of a sequence of 4 bytes. Is there an easy way to test my socket application? Should I just create another application to test it?

like image 641
Imme22009 Avatar asked Sep 27 '13 08:09

Imme22009


1 Answers

You should not be using telnet for this.

Better option is to use netcat.

Then, pipe your command through bash

EG.

echo -n 0x03 | nc 127.0.0.1 1234

like image 140
David Hess Avatar answered Oct 24 '22 00:10

David Hess