From 9a4152eb2d60eb9d3157cf4ae00a3e4700f31a74 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 28 Jan 2002 21:48:00 +0000 Subject: [PATCH] Fixes to make telnet interface work more than 1x. --- simgear/io/sg_socket.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/simgear/io/sg_socket.cxx b/simgear/io/sg_socket.cxx index 2d2b5ded..2d9d4eeb 100644 --- a/simgear/io/sg_socket.cxx +++ b/simgear/io/sg_socket.cxx @@ -339,9 +339,8 @@ int SGSocket::readline( char *buf, int length ) { // cout << "sock_stream\n"; if ( msgsock == INVALID_SOCKET ) { // cout << "msgsock == invalid\n"; - msgsock = accept(sock, 0, 0); - closesocket(sock); - sock = msgsock; + msgsock = sock; + sock = accept(msgsock, 0, 0); } else { // cout << "ready to read\n"; char *buf_ptr = save_buf + save_len; @@ -361,8 +360,7 @@ int SGSocket::readline( char *buf, int length ) { if ( result == 0 && save_len == 0 && first_read == true ) { SG_LOG( SG_IO, SG_ALERT, "Connection closed by foreign host." ); - closesocket(sock); - open( get_dir() ); + close(); } } } else { @@ -494,6 +492,10 @@ bool SGSocket::close() { } closesocket( sock ); + if ( sock_style == SOCK_STREAM && msgsock != INVALID_SOCKET ) { + sock = msgsock; + msgsock = INVALID_SOCKET; + } return true; }