|
UDP client 端能发送出去,但是无法接到数据(跳不到接受回调函数),,帮看看什么问题,各位????是神州的开发板源码,,不知道为什么无法接受到数据 #define UDP_SERVER_PORT 8006, G2 v" k/ K: t) K/ a #define UDP_CLIENT_PORT 4 #define TCP_PORT 4 #define UDP_CLIENT_IP 255,255,255,255+ \% x1 h+ T) N ; M, t" i/ ]# {4 V0 q" { void client_init(void) { struct udp_pcb *upcb;2 h# g/ g. g1 ]# @. R: A8 V struct pbuf *p;8 p! Q& {8 r8 N) y" Z' w 5 m. |/ T5 z$ h4 j8 q. q' Q3 \ /* Create a new UDP control block */ upcb = udp_new(); # j, l: R3 }! _4 w* Y" o SET_IP4_ADDR(&ip_udp_server,UDP_CLIENT_IP);. ?+ O! n: d& @6 w$ e p = pbuf_alloc(PBUF_TRANSPORT, sizeof(Sent), PBUF_RAM);' `# J. z5 B6 ]9 S3 A( z/ T p->payload = (void*)Sent; 7 S7 U6 w' I- Q( R% o( S% Q udp_bind(upcb, IP_ADDR_ANY, 4);; z3 s. _6 \% H* ]0 k: J udp_connect(upcb, &ip_udp_server, UDP_SERVER_PORT); # o9 [, D6 |8 t& b2 ]4 m0 w% H+ [ udp_send(upcb, p); udp_recv(upcb, udp_client_callback, NULL); ( F4 x0 B: _7 F/ |9 c0 Z /* Free the p buffer */% v h% i( N& `% v8 t pbuf_free(p);+ c2 C/ R) Q# x- w& b& p } ; l7 ~+ O; P5 T7 a6 s void udp_client_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port)3 q# n" T4 n0 r6 D4 r7 d& } {( u M6 G8 s9 n1 |8 x" ^; A( z struct tcp_pcb *pcb; __IO uint8_t iptab[4];. V0 ^7 s. Q$ S+ z5 Y* P1 { uint8_t iptxt[20];( M& ~1 {! R9 v/ b' e /* Create a new TCP control block */ pcb = tcp_new();- a. w( t( T" b+ g /* Assign to the new pcb a local IP address and a port number */: P Y1 A. z& l tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT); /* Connect to the server: send the SYN */5 n" B4 h* D! p tcp_connect(pcb, addr, TCP_PORT, tcp_client_connected);6 M- N9 O& e" U& f /* Free the p buffer */& y) B- d/ @; s4 W$ _% T pbuf_free(p); } $ j& @5 t( H' ^$ S. Y/ { |
udp server端
微信公众号
手机版
tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);你是不是指,绑定的本地IP_ADDR_SNY地址有问题?