|

楼主 |
发表于 2021-12-17 21:35:41
|
显示全部楼层
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- #include "lwip/pbuf.h"
- #include "lwip/udp.h"
- #include "lwip/tcp.h"
- #include <string.h>
- #include <stdio.h>
- #include "udp_echoclient.h"
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private function prototypes -----------------------------------------------*/
- void udp_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
- //uint8_t udp_demo_txbuf[UDP_DEMO_RX_BUFSIZE];
- uint8_t udp_demo_rxbuf[UDP_DEMO_RX_BUFSIZE]; //UDP接收数据缓冲区
- __IO uint32_t message_count = 0;
- struct udp_pcb *udppcb;
- uint32_t revCount=0;
- /* Private functions ---------------------------------------------------------*/
- /**
- * @brief Connect to UDP echo server
- * @param None
- * @retval None
- */
- void udp_echoclient_connect(void)
- {
- ip_addr_t DestIPaddr;
- err_t err;
- ip_addr_t thisIp;
-
- /* Create a new UDP control block */
- udppcb = udp_new();
-
- if (udppcb!=NULL)
- {
- /*assign destination IP address */
- IP4_ADDR(&DestIPaddr, 192,168,1,106); //目的地址
复制代码 这是我使用的udp客务端的代码
|
|