新手上路
- 积分
- 46
- 金钱
- 46
- 注册时间
- 2014-7-29
- 在线时间
- 0 小时
|
5金钱
__IO uint8_t iptab[4];
char UDPData[]="LwIP UDP 客户端在 Luminary 微控制器上的测试\r\n";
struct udp_pcb *upcb;
struct pbuf *p;
struct ip_addr *addr;
p=pbuf_alloc(PBUF_RAW, sizeof(UDPData), PBUF_RAM);
p->payload=&UDPData;
addr->addr = htonl(0xc0a80116);
iptab[0] = (uint8_t)((uint32_t)(addr->addr) >> 24);
iptab[1] = (uint8_t)((uint32_t)(addr->addr) >> 16);
iptab[2] = (uint8_t)((uint32_t)(addr->addr) >> 8);
iptab[3] = (uint8_t)((uint32_t)(addr->addr));
printf("\n\rReceiver's IP address:");
printf("%d,%d,%d,%d",iptab[3], iptab[2], iptab[1], iptab[0]);
upcb = udp_new();
udp_bind(upcb, NULL, 7);
udp_connect(upcb, addr, UDP_CLIENT_PORT);
udp_send(upcb, p);
udp_disconnect(upcb);
pbuf_free(p);
|
|