工具/软件:
您好、
我尝试使用 PDK 中的 enet_lwip 示例、添加了一个小的 udp_client 线程、该线程尝试向服务器发送一些消息。
服务器 IP:192.168.3.1
客户端 IP:192.168.3.30
我在 LWIP_APP_init 中添加了一个应用、我们把它称为 CHRIS_UDP_APP、如果 CHRIS_UDP_THREAD 代码是 udp_server、那么它似乎在某种程度上起作用、例如、我可以从 Linux PC 上运行的客户端接收此服务器端口上的数据。
但是、如果我将 CHRIS_UDP_THREAD 代码配置为 udp_client、则会得到错误 udp_send:没有到服务器 IP 地址的路由。
udp_client 线程:
struct sockaddr_in si_other;
int s;
socklen_t slen = sizeof(si_other);
char message[64];
char serv_addr[] = "192.168.3.1";
int PORT = 1264;
if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
puts("socket failed");
return;
}
memset((char *) &si_other, 0, sizeof(si_other));
si_other.sin_family = AF_INET;
si_other.sin_port = htons(PORT);
if (inet_aton(serv_addr , &si_other.sin_addr) == 0)
{
fprintf(stderr, "inet_aton() failed\n");
return;
}
while(1)
{
sprintf(message, "Hello from TI client");
//send the message
if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1)
{
puts("sendto() failed");
return;
}
}
注意:我已禁用配置文件中的所有应用程序、
#define LWIP_CHARGEN_APP 0
还 将其添加到了 test.c 中、