
UDP client 端能发送出去,但是无法接到数据(跳不到接受回调函数),,帮看看什么问题,各位????是神州的开发板源码,,不知道为什么无法接受到数据7 L# j4 k. h7 Q5 t/ Z #define UDP_SERVER_PORT 8006 #define UDP_CLIENT_PORT 4 #define TCP_PORT 46 R9 |, [# Z& f- s* M #define UDP_CLIENT_IP 255,255,255,2552 D. G5 c& M7 Y: ?9 d 4 Z: T0 M, z% `9 T 6 X5 R. W5 `: g! J4 b/ I void client_init(void) {; t6 c8 L3 u' G% k/ y struct udp_pcb *upcb; struct pbuf *p; y8 _9 \2 a. ?- Y/ w% ^3 A ; q/ f" f. Z7 d- _6 \8 M! S /* Create a new UDP control block */ upcb = udp_new(); 3 c6 s7 h; r/ `* c5 P2 p SET_IP4_ADDR(&ip_udp_server,UDP_CLIENT_IP); p = pbuf_alloc(PBUF_TRANSPORT, sizeof(Sent), PBUF_RAM);3 L* ?. S& u8 G& l6 ~: ~ p->payload = (void*)Sent; # _# B$ L& S2 t6 g ; j7 w) O$ _- f# p udp_bind(upcb, IP_ADDR_ANY, 4); udp_connect(upcb, &ip_udp_server, UDP_SERVER_PORT); 1 I0 b/ C, X r5 T6 f udp_send(upcb, p); udp_recv(upcb, udp_client_callback, NULL); 0 {0 }- q# G4 f$ M' C$ B /* Free the p buffer */ pbuf_free(p); } ' g9 e; G" n6 @3 R% o+ x void udp_client_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) {/ @) H: V8 }/ }6 y8 O A struct tcp_pcb *pcb;$ q0 e5 Q7 k$ ~ __IO uint8_t iptab[4];: F# q5 O# w# y3 `) | uint8_t iptxt[20]; /* Create a new TCP control block */ pcb = tcp_new();% \3 k: v. y1 p' e! H /* Assign to the new pcb a local IP address and a port number */, U& s. L% E, g2 B1 l! Y tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);+ R9 R+ B9 A% M! C; e /* Connect to the server: send the SYN */ m @& n, X4 D* o; L& |8 S: O tcp_connect(pcb, addr, TCP_PORT, tcp_client_connected); 7 [6 I8 R2 {" a* P6 B& H$ A /* Free the p buffer */ pbuf_free(p);; \3 [ Q9 `0 V' v' Z, G5 U/ J } a+ E2 B& u/ J5 C |
udp server端
tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);你是不是指,绑定的本地IP_ADDR_SNY地址有问题?