udpecho.c

来自「ADS下基于AT91SAM7X256-EK的可以运行的uCOS-II源码」· C语言 代码 · 共 44 行

C
44
字号
#include "lwip/api.h"#include "lwip/sys.h"/*-----------------------------------------------------------------------------------*/void udpecho_thread(void *arg){struct netconn *conn;struct netbuf *buf;struct ip_addr addr;char text[] = "This is a Test UDP packet.";/* create a new connection */conn = netconn_new(NETCONN_UDP);/* set up the IP address of the remote host */addr.addr = htonl(0xc0a80063);/* connect the connection to the remote host */netconn_connect(conn, &addr, 7000);/* reference the text into the netbuf */netbuf_ref(buf, text, sizeof(text));while(1){/* send the text */netconn_send(conn, buf);}/* deallocate connection and netbuf */netconn_delete(conn);netbuf_delete(buf);}/*-----------------------------------------------------------------------------------*/voidudpecho_init(void){  sys_thread_new(udpecho_thread, NULL,TCPIP_THREAD_PRIO);  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?