forked from xuos/xiuos
Fix Lwip client bug.
This commit is contained in:
parent
82e7002069
commit
8b1a886e13
|
@ -56,7 +56,7 @@
|
||||||
#include <xs_base.h>
|
#include <xs_base.h>
|
||||||
|
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
#define SET_AS_SERVER 1 /* define this terminal is udp server or not*/
|
// #define SET_AS_SERVER 1 /* define this terminal is udp server or not*/
|
||||||
|
|
||||||
#define LOCAL_PORT_SERVER 5001
|
#define LOCAL_PORT_SERVER 5001
|
||||||
#define TARGET_PORT_CLIENT LOCAL_PORT_SERVER
|
#define TARGET_PORT_CLIENT LOCAL_PORT_SERVER
|
||||||
|
|
|
@ -107,6 +107,7 @@ static void UdpEchoThreadServer(void *arg)
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
memset(recv_data, 0, RECV_DATA);
|
||||||
recv_data_len=recvfrom(sock,recv_data,
|
recv_data_len=recvfrom(sock,recv_data,
|
||||||
RECV_DATA,0,
|
RECV_DATA,0,
|
||||||
(struct sockaddr*)&seraddr,
|
(struct sockaddr*)&seraddr,
|
||||||
|
@ -131,7 +132,7 @@ __exit:
|
||||||
static void UdpEchoThreadClient(void *arg)
|
static void UdpEchoThreadClient(void *arg)
|
||||||
{
|
{
|
||||||
KPrintf("UdpEchoThreadClient start.\n");
|
KPrintf("UdpEchoThreadClient start.\n");
|
||||||
MdelayKTask(5000);
|
|
||||||
int sock_udp_send_once = -1;
|
int sock_udp_send_once = -1;
|
||||||
sock_udp_send_once = socket(AF_INET, SOCK_DGRAM, 0);
|
sock_udp_send_once = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sock_udp_send_once < 0)
|
if (sock_udp_send_once < 0)
|
||||||
|
@ -155,17 +156,20 @@ static void UdpEchoThreadClient(void *arg)
|
||||||
KPrintf("UDP connect sucess, start to send.\n");
|
KPrintf("UDP connect sucess, start to send.\n");
|
||||||
KPrintf("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
KPrintf("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
||||||
|
|
||||||
sendto(sock_udp_send_once,send_msg,
|
|
||||||
strlen(send_msg),0,
|
|
||||||
(struct sockaddr*)&udp_sock,
|
|
||||||
sizeof(struct sockaddr));
|
|
||||||
|
|
||||||
KPrintf("Send UDP msg: %s ", send_msg);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
KPrintf("Lwip client is running.\n");
|
KPrintf("Lwip client is running.\n");
|
||||||
MdelayKTask(3000);
|
|
||||||
|
sendto(sock_udp_send_once,send_msg,
|
||||||
|
strlen(send_msg),0,
|
||||||
|
(struct sockaddr*)&udp_sock,
|
||||||
|
sizeof(struct sockaddr));
|
||||||
|
|
||||||
|
KPrintf("Send UDP msg: %s ", send_msg);
|
||||||
|
|
||||||
|
MdelayKTask(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
__exit:
|
__exit:
|
||||||
|
|
Loading…
Reference in New Issue