Skip to content

Commit

Permalink
Set socket options SO_KEEPALIVE and TCP_NODELAY for embedded Telnet s…
Browse files Browse the repository at this point in the history
…erver. Ref #1335
  • Loading branch information
grossmj committed Jan 12, 2019
1 parent a896346 commit bb284d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gns3server/utils/asyncio/telnet_server.py
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import socket
import asyncio
import asyncio.subprocess
import struct
Expand Down Expand Up @@ -184,6 +185,12 @@ async def _write_intro(self, writer, binary=False, echo=False, naws=False):
await writer.drain()

async def run(self, network_reader, network_writer):

sock = network_writer.get_extra_info("socket")
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
#log.debug("New connection from {}".format(sock.getpeername()))

# Keep track of connected clients
connection = self._connection_factory(network_reader, network_writer, self._window_size_changed_callback)
self._connections[network_writer] = connection
Expand Down

0 comments on commit bb284d0

Please sign in to comment.