在RL-TCPnet下的UDP通信
2010-01-29 12:24
141 查看
1. 初始化TCPnet。
void init_TcpNet (void);
2. 分配自由的UDP Socket。
U8 udp_get_socket (
U8 tos, /* Type Of Service. */
U8 opt, /* Option to calculate or verify the checksum. */
U16 (*listener)(/* Function to call when TCPnet receives a data packet. */
U8 socket, /* Socket handle of the local machine. */
U8* remip, /* Pointer to IP address of remote machine. */
U16 port, /* Port number of remote machine. */
U8* buf, /* Pointer to buffer containing the received data. */
U16 len ));
Listener是udp的事件侦听函数,TCPnet随时在收到一个UDP包时调用它。
3. 打开它。
BOOL udp_open (
U8 socket, /* Socket handle to use for communication. */
U16 locport); /* Local port to use for communication. */
4. 运行TCPnet的主线程。
void main_TcpNet (void);
5. 监听或发送。
BOOL udp_send (
U8 socket, /* UDP socket to send the data packet from. */
U8* remip, /* Pointer to the IP address of the remote machine. */
U16 remport, /* Port number of remote machine to send the data to. */
U8* buf, /* Pointer to buffer containing the data to send. */
U16 dlen ); /* Number of bytes of data to send. */
注意:在发送数据时,必须用udp_get_buf为udp_send()函数分配内存。
U8* udp_get_buf ( U16 size); /* Number of bytes to be sent. */
6. 其他。
void init_TcpNet (void);
2. 分配自由的UDP Socket。
U8 udp_get_socket (
U8 tos, /* Type Of Service. */
U8 opt, /* Option to calculate or verify the checksum. */
U16 (*listener)(/* Function to call when TCPnet receives a data packet. */
U8 socket, /* Socket handle of the local machine. */
U8* remip, /* Pointer to IP address of remote machine. */
U16 port, /* Port number of remote machine. */
U8* buf, /* Pointer to buffer containing the received data. */
U16 len ));
Listener是udp的事件侦听函数,TCPnet随时在收到一个UDP包时调用它。
3. 打开它。
BOOL udp_open (
U8 socket, /* Socket handle to use for communication. */
U16 locport); /* Local port to use for communication. */
4. 运行TCPnet的主线程。
void main_TcpNet (void);
5. 监听或发送。
BOOL udp_send (
U8 socket, /* UDP socket to send the data packet from. */
U8* remip, /* Pointer to the IP address of the remote machine. */
U16 remport, /* Port number of remote machine to send the data to. */
U8* buf, /* Pointer to buffer containing the data to send. */
U16 dlen ); /* Number of bytes of data to send. */
注意:在发送数据时,必须用udp_get_buf为udp_send()函数分配内存。
U8* udp_get_buf ( U16 size); /* Number of bytes to be sent. */
6. 其他。
相关文章推荐
- 【RL-TCPnet网络教程】第16章 UDP用户数据报协议基础知识
- 高性能 TCP/UDP/HTTP 通信框架 HP-Socket v4.1.2
- Java Socket(套接字)编程、TCP和UDP通信过程详解
- Linux 下socket通信终极指南(附TCP、UDP完整代码)
- .Net TCP/UDP 编程
- Socket 通信原理(Android客户端和服务器以TCP&&UDP方式互通)
- Socket 通信原理(Android客户端和服务器以TCP&&UDP方式互通)
- 高性能 TCP & UDP 通信框架 HP-Socket v3.3.1 正式发布
- Linux网络通信(二)Socket编写TCP/UDP
- TCP与UDP通信协议及Java实现
- TCP与UDP通信协议及Java实现
- 通信协议——Http、TCP、UDP
- 高性能 TCP & UDP 通信框架 HP-Socket v3.2.3 正式发布
- Socket 通信原理(Android客户端和服务器以TCP&&UDP方式互通)
- .Net Micro Framework研究—TCP/IP通信
- C语言编写基于TCP和UDP协议的Socket通信程序示例
- Android UDP通信的简单实例和用法归纳,以及与TCP对比、常见问题
- C++的TCP/UDP通信实现
- Java网络编程中的TCP,UDP通信方式详解
- 高性能 TCP & UDP 通信框架 HP-Socket v3.4.1 正式发布