INNER CODE UNIT · Python

connect_to_feed

nordnet/next-api-v2-examples · python3/test_program.py:128

def connect_to_feed(public_feed_hostname, public_feed_port):
    """
    Connect to the feed and get back a TCP socket
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    if public_feed_port == 443:
        c = ssl.create_default_context()
        s = c.wrap_socket(s, server_hostname=public_feed_hostname)
    s.connect((public_feed_hostname, public_feed_port))
    return s

def send_cmd_to_socket(socket, cmd):
    """
    Send commands to the feed through the socket
    """
    socket.send(bytes(json.dumps(cmd) + '\n', 'utf-8'))
    print("<< Sending cmd to feed: " + str(cmd))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…