
UDP client 端能发送出去,但是无法接到数据(跳不到接受回调函数),,帮看看什么问题,各位????是神州的开发板源码,,不知道为什么无法接受到数据( J# Q; X7 \! H# p( B# C9 u #define UDP_SERVER_PORT 8006 #define UDP_CLIENT_PORT 4 #define TCP_PORT 4 #define UDP_CLIENT_IP 255,255,255,255 / l S; _6 }3 ]6 N0 f void client_init(void). A! C* l) L3 z, Z' j7 _+ V9 X { struct udp_pcb *upcb;9 N0 u! D+ U( [, z B1 y struct pbuf *p; 7 J3 n$ o, A6 E /* Create a new UDP control block */+ M$ J, r1 h% [! j upcb = udp_new(); 0 B5 O1 O6 l8 u6 I6 \& ^ 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); : f2 B( S, d( B; m2 b8 b udp_send(upcb, p); udp_recv(upcb, udp_client_callback, NULL); 4 y; d" E1 K% n; `% {2 e /* Free the p buffer */3 k1 [/ H i1 ~2 H) @ pbuf_free(p);& G% ?0 ]" z; J } % C. V) ^0 B) ]3 n* T5 w( m void udp_client_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) {$ P3 P4 o6 ~3 _& ~5 D struct tcp_pcb *pcb;3 t$ u' C$ `; j6 C! B8 k- ^' K __IO uint8_t iptab[4]; uint8_t iptxt[20];( o& W' K# y! L5 { /* Create a new TCP control block */% J! ~8 Z T. S; d; |4 v pcb = tcp_new(); X8 R9 O# a4 Y' x * I! Q6 Z) e1 k5 @/ L3 c) C* p /* Assign to the new pcb a local IP address and a port number */ tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);) f2 L8 Z7 k; Z% x. y6 g# ? /* Connect to the server: send the SYN */3 @" a/ T; I$ N, q% { tcp_connect(pcb, addr, TCP_PORT, tcp_client_connected); ) U% j% b( p6 H+ l6 n: B. Z /* Free the p buffer */ pbuf_free(p); } : M" A; ?5 ^( v4 a" W |
udp server端
tcp_bind(pcb, IP_ADDR_ANY, TCP_PORT);你是不是指,绑定的本地IP_ADDR_SNY地址有问题?