11# -*- coding: utf-8 -*-
2- # Copyright (C) 2009, 2013-2015 Rocky Bernstein <rocky@gnu.org>
2+ # Copyright (C) 2009, 2013-2015, 2025 Rocky Bernstein <rocky@gnu.org>
33#
44# This program is free software: you can redistribute it and/or modify
55# it under the terms of the GNU General Public License as published by
1616"""Debugger Socket Input/Output Interface."""
1717
1818import socket
19+ from typing import Final
1920
20- from trepan .lib import default as Mdefault
21+ from trepan .lib . default import CLIENT_SOCKET_OPTS
2122from trepan .inout import tcpfns as Mtcpfns
2223from trepan .inout .base import DebuggerInOutBase
2324from trepan .misc import option_set
2627class TCPClient (DebuggerInOutBase ):
2728 """Debugger Client Input/Output Socket."""
2829
29- DEFAULT_INIT_OPTS = {"open" : True }
30+ DEFAULT_INIT_OPTS : Final = {"open" : True }
3031
3132 def __init__ (self , inout = None , opts = None ):
32- get_option = lambda key : option_set (opts , key , Mdefault . CLIENT_SOCKET_OPTS )
33+ get_option = lambda key : option_set (opts , key , CLIENT_SOCKET_OPTS )
3334 self .inout = None
3435 self .addr = None
3536 self .buf = ""
@@ -52,13 +53,13 @@ def close(self):
5253
5354 def open (self , opts = None ):
5455
55- get_option = lambda key : option_set (opts , key , Mdefault . CLIENT_SOCKET_OPTS )
56+ get_option = lambda key : option_set (opts , key , CLIENT_SOCKET_OPTS )
5657
5758 HOST = get_option ("HOST" )
5859 PORT = get_option ("PORT" )
5960 self .inout = None
6061 for res in socket .getaddrinfo (HOST , PORT , socket .AF_UNSPEC , socket .SOCK_STREAM ):
61- af , socktype , proto , canonname , sa = res
62+ af , socktype , proto , _ , sa = res
6263 try :
6364 self .inout = socket .socket (af , socktype , proto )
6465 self .state = "connected"
@@ -72,7 +73,6 @@ def open(self, opts=None):
7273 self .inout .close ()
7374 self .inout = None
7475 continue
75- break
7676 if self .inout is None :
7777 raise IOError ("could not open client socket on port %s" % PORT )
7878 return
0 commit comments