Fix Lwip client bug.
This commit is contained in:
parent
82e7002069
commit
8b1a886e13
|
@ -56,7 +56,7 @@
|
|||
#include <xs_base.h>
|
||||
|
||||
/* 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 TARGET_PORT_CLIENT LOCAL_PORT_SERVER
|
||||
|
|
|
@ -107,6 +107,7 @@ static void UdpEchoThreadServer(void *arg)
|
|||
|
||||
while(1)
|
||||
{
|
||||
memset(recv_data, 0, RECV_DATA);
|
||||
recv_data_len=recvfrom(sock,recv_data,
|
||||
RECV_DATA,0,
|
||||
(struct sockaddr*)&seraddr,
|
||||
|
@ -131,7 +132,7 @@ __exit:
|
|||
static void UdpEchoThreadClient(void *arg)
|
||||
{
|
||||
KPrintf("UdpEchoThreadClient start.\n");
|
||||
MdelayKTask(5000);
|
||||
|
||||
int sock_udp_send_once = -1;
|
||||
sock_udp_send_once = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock_udp_send_once < 0)
|
||||
|
@ -155,6 +156,12 @@ static void UdpEchoThreadClient(void *arg)
|
|||
KPrintf("UDP connect sucess, start to send.\n");
|
||||
KPrintf("\n\nTarget Port:%d\n\n", udp_sock.sin_port);
|
||||
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
KPrintf("Lwip client is running.\n");
|
||||
|
||||
sendto(sock_udp_send_once,send_msg,
|
||||
strlen(send_msg),0,
|
||||
(struct sockaddr*)&udp_sock,
|
||||
|
@ -162,10 +169,7 @@ static void UdpEchoThreadClient(void *arg)
|
|||
|
||||
KPrintf("Send UDP msg: %s ", send_msg);
|
||||
|
||||
while (1)
|
||||
{
|
||||
KPrintf("Lwip client is running.\n");
|
||||
MdelayKTask(3000);
|
||||
MdelayKTask(1000);
|
||||
}
|
||||
|
||||
__exit:
|
||||
|
|
Loading…
Reference in New Issue