#NEWLINE# def send_client_hello( host , port , data ) : #NEWLINE# #INDENT# '\n    Sends a ClientHello message in bytes.\n\n    Returns a ServerHello message in bytes\n\n    ' #NEWLINE# try : #NEWLINE# #INDENT# s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) #NEWLINE# s . connect ( ( host , port ) ) #NEWLINE# s . send ( data ) #NEWLINE# server_hello = s . recv ( 5 ) #NEWLINE# if ( len ( server_hello ) == 0 ) : #NEWLINE# #INDENT# raise HandshakeFailure ( ) #NEWLINE# #UNINDENT# server_hello += s . recv ( UBInt16 ( 'length' ) . parse ( server_hello [ 3 : 5 ] ) ) #NEWLINE# return server_hello #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# raise HandshakeFailure ( )