• B

    Thank you, Phil. I could play with the message sizes and see if that works well with no unintended side effects. Seeing as how the TCP/IP data source is character oriented, it might make sense to be able to specify a character to be interpreted as end of stream. (like maybe EOT (\004) or something).

    One other related question: Is it possible to make the polling rate faster than once per second? For my application, a faster poll would be better.

    Thank you again for your help!

    posted in User help read more
  • B


    (( sorry, not clear why the code below is formatting like that ))

    I am unclear on the correct way for my TCP socket server to behave to satisfy what the Mango client is looking for. In the help box for the TCPIP data source, there is this statement: "The timeout determines when to abandon listening for a completed response, a timeout of 0 means no timeout. When using a timeout if a message is received with no EOF (end of file) or connection close, then the message will not be processed until after the timeout has been reached." I see this behavior exactly. Looking at Mango's tcpipIO log file, I see the "I" response occurring exactly after the "O" command string by the specified timeout value in the TCPIP data source.

    How would the TCPIP server send an EOF back to Mango? I have tried closing the connection for each poll from Mango, but that results in lost messages (every other one). The little test loop I am testing Mango with is as shown below. Note that using a timeout of zero seems to work fine and causes no problems in the test configuration, but I would like to understand how to use this data source as intended by Mango.

    Any help would be appreciated! Thank you.

    import socket
    import sys
    import time

    HOST = ''
    PORT = 7001

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print('# Socket created')

    --Create socket on port
    s.bind((HOST, PORT))
    except socket.error as msg:
    print('# Bind failed. ')

    print('# Socket bind complete')

    -- Start listening on socket
    print('# Socket now listening')

    -- Wait for client
    conn, addr = s.accept()
    print('# Connected to ' + addr[0] + ':' + str(addr[1]) + "@" + time.strftime("%H:%M:%S") )
    value = 123

    -- Receive data from client
    while True:

       # Wait for client
       data = conn.recv(1024)
       line = data.decode('UTF-8')    # convert to string (Python 3 only)
       line = line.replace("\n","")   # remove newline character
       if len(line) > 1 :
            print "   INPUT ==  " + line
            if line == "BZNREAD" :
                value = value + 1
                data = str(value) + "\n"
                print "   RSP -> " + data + "\n"
                conn.send(data.encode())  # send data to the client

    except socket.error as msg:
    print "Closing socket\n"

    posted in User help read more