[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Socket receive timeout wrong
From: |
Fabian Cenedese |
Subject: |
[lwip-users] Socket receive timeout wrong |
Date: |
Wed, 13 Mar 2013 14:52:03 +0100 |
Hi
I want to receive with the socket interface which works good.
However if no partner is connected I wanted to cancel the
receive with a timeout. But it looks like lwip interprets the
time wrongly.
What I did:
#define LWIP_SO_RCVTIMEO 1
struct timeval tv;
tv.tv_sec = 3; /* 3 Secs Timeout */
tv.tv_usec = 0;
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));
whereas struct timeval is defined as
struct timeval {
long tv_sec;
long tv_usec;
};
This struct is then used for setting the timeout like this
netconn_set_recvtimeout(sock->conn, *(int*)optval);
which is just
conn->recv_timeout=...
So it will store the seconds from the timeval struct. But this same value
is used for
sys_arch_mbox_fetch(&mbox, (void **)&conn, conn->recv_timeout)
which interprets the time as milliseconds. So a timeout of 3 seconds
suddenly becomes 3 milliseconds. If I set the timeout to 3000 then
the call returns after about 3 seconds.
Is this an error in the code or in the documentation? Is this already fixed
in the repository?
Thanks
bye Fabi
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] Socket receive timeout wrong,
Fabian Cenedese <=