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