Merge branch 'master' of github.com:john30/ebusd
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "lib/utils/log.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -95,6 +95,17 @@ class TCPSocket {
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Set the timeout for @a send and @a recv.
|
||||
* @param timeout the timeout in seconds.
|
||||
*/
|
||||
void setTimeout(int timeout) {
|
||||
struct timeval t;
|
||||
t.tv_usec = 0;
|
||||
t.tv_sec = timeout;
|
||||
setsockopt(m_sfd, SO_RCVTIMEO, SO_REUSEADDR, &t, sizeof(t));
|
||||
setsockopt(m_sfd, SO_SNDTIMEO, SO_REUSEADDR, &t, sizeof(t));
|
||||
}
|
||||
|
||||
private:
|
||||
/** file descriptor from tcp socket */
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD_SETNAME_NP
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "lib/utils/thread.h"
|
||||
#include "lib/utils/clock.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user