1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 00:38:10 +00:00

Set socket options SO_KEEPALIVE and TCP_NODELAY for embedded Telnet server. Ref #1335

This commit is contained in:
grossmj 2019-01-12 16:50:15 +07:00
parent a896346c77
commit bb284d082a

View File

@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import socket
import asyncio import asyncio
import asyncio.subprocess import asyncio.subprocess
import struct import struct
@ -184,6 +185,12 @@ class AsyncioTelnetServer:
await writer.drain() await writer.drain()
async def run(self, network_reader, network_writer): 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 # Keep track of connected clients
connection = self._connection_factory(network_reader, network_writer, self._window_size_changed_callback) connection = self._connection_factory(network_reader, network_writer, self._window_size_changed_callback)
self._connections[network_writer] = connection self._connections[network_writer] = connection