/*
net_socket.c -- Handle various kinds of sockets.
- Copyright (C) 1998-2003 Ivo Timmermans <ivo@o2w.nl>,
- 2000-2003 Guus Sliepen <guus@sliepen.eu.org>
+ Copyright (C) 1998-2004 Ivo Timmermans <ivo@tinc-vpn.org>,
+ 2000-2004 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net_socket.c,v 1.1.2.38 2003/12/22 11:04:16 guus Exp $
+ $Id$
*/
#include "system.h"
int addressfamily = AF_UNSPEC;
int maxtimeout = 900;
int seconds_till_retry = 5;
+bool blockingtcp = false;
listen_socket_t listen_socket[MAXSOCKETS];
int listen_sockets;
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
+#ifdef O_NONBLOCK
+ if(blockingtcp) {
+ int flags = fcntl(c->socket, F_GETFL);
+
+ if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) {
+ logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
+ }
+ }
+#endif
+
c->last_ping_time = now;
send_id(c);
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
+#ifdef O_NONBLOCK
+ if(blockingtcp) {
+ int flags = fcntl(c->socket, F_GETFL);
+
+ if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) {
+ logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
+ }
+ }
+#endif
+
connection_add(c);
c->allow_request = ID;