Ejemplo n.º 1
0
def SendNumOfNode(conn, numOfNode):

    st.SocketSend_uint64(conn, numOfNode)

    if st.SocketRecvPack(conn) != 'OK':
        raise RuntimeError('Server doesn\'t accept the numOfNode=' +
                           numOfNode + ' !')
Ejemplo n.º 2
0
def GetServerConnection(svrAddr, svrPort, totalClient, clientI, retryTimeList):

    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    isConnected = False
    retryCount = 0

    while isConnected is False:
        try:
            conn.connect((svrAddr, svrPort))
            isConnected = True
        except Exception:
            print('Failed to connect to the Tester Server.', 'Retry later...')
            waitTime = retryTimeList[retryCount if retryCount < len(
                retryTimeList) else len(retryTimeList) - 1]
            if waitTime < 0:
                raise
            else:
                WaitFor(waitTime)
            retryCount = retryCount + 1

    st.SocketSend_uint64(conn, totalClient)
    st.SocketSend_uint64(conn, clientI)

    return conn