明远智睿技术论坛

标题: imx8m使用TCP通信 [打印本页]

作者: KWH    时间: 2020-4-30 08:21
标题: imx8m使用TCP通信
主机平台: UBUNTU14.04
硬件平台:明远智睿MY-IMX8M-EK300
内核版本 :linux-4.14.98
交叉编译链:
aarch64-linux-gnu
文件系统:fsl-image-validation-myimx8m.tar.bz2


源码加编译好的执行文件:见附件


编译:
1.设置交叉编译工具:
$ source /home/myzr/my-work/imx8m/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env


2.解压压缩包:
$ tar xvf tcp.tar.bz2


3.进入server目录进行编译:
$ cd server
$ $CC server.c -o server.out


测试:
1.把可执行文件server.out移植到开发板中
2.运行:
$./server.out
3.在虚拟机中client目录运行:
$./client 192.168.137.81(开发板ip地址)
4.可在开发板中接收到数据:
OK: Obtain Socket Despcritor sucessfully.
OK: Bind the Port 5000 sucessfully.
OK: Listening the Port 5000 sucessfully.
OK: Server has got connect from 192.168.137.83.
You can enter string, and press 'exit' to end the connect.

5.在开发板中输入字符,可在虚拟机中接收到:
You can enter string, and press 'exit' to end the connect.
www.myzr.com
OK: Sent 12 bytes sucessful, please enter again.





欢迎光临 明远智睿技术论坛 (http://bbs.myzr.com.cn/) Powered by Discuz! X3.2