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.

如何发送一个字节(或字节)来测试正在我的应用程序中的端口上侦听的TCP套接字?我的应用程序收到一个字节,告诉它该做什么。某些操作将接收额外的字节以进一步指示它。

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

我已经尝试过使用Telnet,但是当我输入int值时,它似乎发送了int(4个字节)。

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?

我只需要发送一个字节(8位),而不是4字节的序列。有没有简单的方法来测试我的套接字应用程序?我应该创建另一个应用程序来测试它吗?

1 个解决方案

#1


6

You should not be using telnet for this.

你不应该使用telnet。

Better option is to use netcat.

更好的选择是使用netcat。

Then, pipe your command through bash

然后,通过bash管理你的命令

EG.

echo -n 0x03 | nc 127.0.0.1 1234

echo -n 0x03 | nc 127.0.0.1 1234

更多相关文章

  1. 〖Linux〗使用Qt5.2.0开发Android的NDK应用程序
  2. 如何测试已部署的Web应用程序
  3. 嵌入式linux 字节对齐 导致输出Alignment trap
  4. window下使用vnc远程登录linux图形界面和运行应用程序 和odroid
  5. [求助][CAB][安装包][CF2.0][SQL][setup]1000分请教:如何将CF2.0
  6. 【JavaWeb-6】HttpServletResponse的字符字节输出流、编码、文件
  7. 为什么我们应该将XMPP而不是JSON用于简单(仅文本)消息传递应用程序
  8. Android - 在一个应用程序中启动另外一个已经安装的应用程序或系
  9. Android混合应用程序:JQueryMobile ajax不支持https,但可以使用htt

随机推荐

  1. 面试官:手写一个冒泡排序,并对其改进
  2. 动手DIY制作个人NAS(一):3D打印硬盘支架
  3. 面试官:手写一个归并排序,并对其改进
  4. java中的对称加密算法
  5. Android碎片(一)
  6. 面试官:java中的编码转化方式都有哪些?(中兴
  7. 五分钟学会java中的基础类型封装类
  8. 设计模式之中介者模式
  9. 数字签名的原理是什么?这篇文章给你答案(ja
  10. 面试官:手写一个希尔排序,并对其改进