(data,host,port)
return response
Helper function to send/receive DNS TCP request
        (in/out packets will have prepended TCP length header)
Helper function to send/receive DNS TCP request
        (in/out packets will have prepended TCP length header)
Helper function to send / receive DNS TCP request ( in / out packets will have prepended TCP length header )
def send_tcp(data,host,port):
    """
        Helper function to send/receive DNS TCP request
        (in/out packets will have prepended TCP length header)
    """
    sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    sock.connect((host,port))
    sock.sendall(data)
    response = sock.recv(8192)
    length = struct.unpack("!H",bytes(response[:2]))[0]
    while len(response) - 2 < length:
        response += sock.recv(8192)
    sock.close()
    return response
def send_tcp ( data , host , port ) : sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) sock . connect ( ( host , port ) ) sock . sendall ( data ) response = sock . recv ( 8192 ) length = struct . unpack ( "!H" , bytes ( response [ : 2 ] ) ) [ 0 ] while len ( response ) - 2 < length : response += sock . recv ( 8192 ) sock . close ( ) return response