def read_ros_handshake_header(sock, b, buff_size):
 header_str = None
 while (not header_str):
  d = sock.recv(buff_size)
  if (not d):
   raise ROSHandshakeException(('connection from sender terminated before handshake header received. %s bytes were received. Please check sender for additional details.' % b.tell()))
  b.write(d)
  btell = b.tell()
  if (btell > 4):
   bval = b.getvalue()
   (size,) = struct.unpack('<I', bval[0:4])
   if ((btell - 4) >= size):
    header_str = bval
    leftovers = bval[(size + 4):]
    b.truncate(len(leftovers))
    b.seek(0)
    b.write(leftovers)
    header_recvd = True
 return decode_ros_handshake_header(bval)

def read_ros_handshake_header ( sock , b , buff_size ) : header_str = None while ( not header_str ) : d = sock . recv ( buff_size ) if ( not d ) : raise ROSHandshakeException ( ( 'connection from sender terminated before handshake header received. %s bytes were received. Please check sender for additional details.' % b . tell ( ) ) ) b . write ( d ) btell = b . tell ( ) if ( btell > 4 ) : bval = b . getvalue ( ) ( size , ) = struct . unpack ( '<I' , bval [ 0 : 4 ] ) if ( ( btell - 4 ) >= size ) : header_str = bval leftovers = bval [ ( size + 4 ) : ] b . truncate ( len ( leftovers ) ) b . seek ( 0 ) b . write ( leftovers ) header_recvd = True return decode_ros_handshake_header ( bval )
read in tcpros header off the socket  sock using buffer  b .