diff --git a/simgear/io/sg_socket.cxx b/simgear/io/sg_socket.cxx index 4012d71a..7407f6ec 100644 --- a/simgear/io/sg_socket.cxx +++ b/simgear/io/sg_socket.cxx @@ -42,7 +42,8 @@ SGSocket::SGSocket( const string& host, const string& port_, client(0), is_tcp(false), is_server(false), - first_read(false) + first_read(false), + timeout(0) { if (!init) { @@ -386,7 +387,7 @@ SGSocket::poll() netSocket* writers[1]; writers[0] = 0; - int result = netSocket::select( readers, writers, 0 ); + int result = netSocket::select( readers, writers, timeout ); if (result > 0 && is_server && client == 0) { diff --git a/simgear/io/sg_socket.hxx b/simgear/io/sg_socket.hxx index 4e1d9e05..704e67d3 100644 --- a/simgear/io/sg_socket.hxx +++ b/simgear/io/sg_socket.hxx @@ -64,6 +64,7 @@ private: bool is_tcp; bool is_server; bool first_read; + int timeout; static bool init; @@ -156,6 +157,9 @@ public: */ bool nonblock(); + // set timeout (default: 0) + inline void set_timeout(int i) { timeout = i; } + /** @return the remote host name */ inline string get_hostname() const { return hostname; }