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

StackOverflow https://stackoverflow.com/questions/19046717

  •  29-06-2022
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top