[求助] 用了altera 的demo simple socket server程序,请问有没有udp的demo 程序可
- UID
- 137844
- 性别
- 男
|
[求助] 用了altera 的demo simple socket server程序,请问有没有udp的demo 程序可
|
|
|
|
|
- UID
- 137844
- 性别
- 男
|
初始化网络用的是simple socket server那段,然后实现如下
static void udp_test_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p,
struct ip_addr *addr, u16_t port)
{
/*
printf("\nUDP packet received from: %d.%d.%d.%d : %d",
(addr->addr)&0xFF, ((addr->addr)>>8)&0xFF,
((addr->addr)>>16)&0xFF, (addr->addr)>>24, port);
*/
udp_packets++;
//printf("\nlen: %d, tot_len: %d", p->len, p->tot_len);
if (udp_packets % 1024 == 0)
printf("\n%d udp_packets received", udp_packets);
pbuf_free(p);
}
struct udp_pcb *pcb;
struct pbuf* pbuflfsr;
struct ip_addr udpDestIpAddr,udpLocalIpAddr;
pbuf_layer layer=PBUF_TRANSPORT;
pbuf_flag flag=PBUF_RAM;
u16_t size=1500;
IP4_ADDR(&udpDestIpAddr, 10, 0, 0, 52);
IP4_ADDR(&udpLocalIpAddr, 10, 0, 0, 51);
printf("udp_init\n");
udp_packets = 0;
pcb = udp_new();
udp_bind(pcb, &udpLocalIpAddr, 30);
udp_connect(pcb, &udpDestIpAddr,30);
pbuflfsr = pbuf_alloc(layer,size,flag); //Get a pbuf struct.
for(i=0;i<=size-1;i++)
{
((u8_t *)(pbuflfsr->payload)) = 0x11;
}
while(1)
{
udp_sendto(pcb, pbuflfsr, &udpDestIpAddr, 30);
}
大概就是这样,可以看到开发板开始在发送东西,开发板网口灯开始闪
另一边的计算机网卡属性显示开始收到消息包,但是指定的端口收不到消息
请问原因
|
|
|
|
|
|