
UDP client 端能发送出去,但是无法接到数据(跳不到接受回调函数),,帮看看什么问题,各位????是神州的开发板源码,,不知道为什么无法接受到数据 #define UDP_SERVER_PORT 8006 #define UDP_CLIENT_PORT 4 #define TCP_PORT 4 #define UDP_CLIENT_IP 255,255,255,255 void client_init(void) { struct udp_pcb *upcb; struct pbuf *p; /* Create a new UDP control block */ upcb = udp_new(); SET_IP4_ADDR(&ip_udp_server,UDP_CLIENT_IP); p = pbuf_alloc(PBUF_TRANSPORT, sizeof(Sent), PBUF_RAM); p->payload = (void*)Sent; udp_bind(upcb, IP_ADDR_ANY, 4); udp_connect(upcb, &ip_udp_server, UDP_SERVER_PORT); udp_send(upcb, p); udp_recv(upcb, udp_client_callback, NULL); /* Free the p buffer */ pbuf_free(p); } void udp_client_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { struct tcp_pcb *pcb; __IO uint8_t iptab[4]; uint8_t iptxt[20]; /* Create a new TCP control block */ pcb = tcp_new(); /* Assign to the new pcb a local IP address and a port number */ tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT); /* Connect to the server: send the SYN */ tcp_connect(pcb, addr, TCP_PORT, tcp_client_connected); /* Free the p buffer */ pbuf_free(p); } |
udp server端
tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);你是不是指,绑定的本地IP_ADDR_SNY地址有问题?