There's another problem with sg_socket.cxx: the timeout value is
hardcoded as 0. This is appropriate for servers as they continuously
poll the socket and never want to wait for clients. But clients
*do* want to wait a few seconds for a server response.
client(0),
is_tcp(false),
is_server(false),
- first_read(false)
+ first_read(false),
+ timeout(0)
{
if (!init)
{
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)
{
bool is_tcp;
bool is_server;
bool first_read;
+ int timeout;
static bool init;
*/
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; }