matlab gui下的tcp client客户端编程框架

GUI界面

函数外定义全局变量

%全局变量

global TcpClient; %matlab作为tcpip客户端

建立连接

在"连接"按钮的回调函数下添加以下代码:

global TcpClient;%全局变量

TcpClient = tcpip('192.168.1.10', 7, 'NetworkRole','client'); %连接到服务器地址和端口号

fopen(TcpClient);%与一个服务器建立连接,直到建立完成返回,否则报错。

发送数据

在"发送""按钮的回调函数下添加以下代码:

global TcpClient;

data = [hex2dec('A1') hex2dec('00') hex2dec('00') hex2dec('FF') hex2dec('FE') hex2dec('00') hex2dec('00') hex2dec('00') hex2dec('00') hex2dec('0D') hex2dec('0A')];

fwrite(TcpClient, data);%写入(发送)数据

相关推荐
诸神黄昏EX1 天前
Android Build系列专题【篇四:编译相关语法】
android
雨白1 天前
优雅地处理协程:取消机制深度剖析
android·kotlin
leon_zeng01 天前
更改 Android 应用 ID (ApplicationId) 后遭遇记
android·发布
疯狂吧小飞牛1 天前
ip rule 策略路由
linux·网络·tcp/ip·运维开发
2501_916007471 天前
iOS 混淆工具链实战,多工具组合完成 IPA 混淆与加固(iOS混淆|IPA加固|无源码混淆|App 防反编译)
android·ios·小程序·https·uni-app·iphone·webview
hour_go1 天前
TCP/IP协议相关知识点
网络·笔记·网络协议·tcp/ip
Jeled1 天前
Retrofit 与 OkHttp 全面解析与实战使用(含封装示例)
android·okhttp·android studio·retrofit
嫄码1 天前
TCP/IP 四层模型
网络·网络协议·tcp/ip
ii_best1 天前
IOS/ 安卓开发工具按键精灵Sys.GetAppList 函数使用指南:轻松获取设备已安装 APP 列表
android·开发语言·ios·编辑器
2501_915909061 天前
iOS 26 文件管理实战,多工具组合下的 App 数据访问与系统日志调试方案
android·ios·小程序·https·uni-app·iphone·webview