Windows: q can listen on same port as other app

81 views
Skip to first unread message

Péter Györök

unread,
Jun 5, 2017, 8:39:18 AM6/5/17
to Kdb+ Personal Developers
I just found out that q can listen on the same port as another app. For example, one of the processes with a listening socket:
nvcontainer.exe    3180    TCP    LAPTOP    65000    LAPTOP    0    LISTENING                                       
And if I do \p 65000 in a q process, I will see this, together with the above:
q.exe    6568    TCP    LAPTOP    65000    LAPTOP    0    LISTENING                                       

But if I try to do this with two q processes, I get the error about the port already being in use.

There's more strange behavior if I have a C++ app that uses c.dll to connect to a q process and also tries to open a listening socket. If the C++ app tries to listen on the same port as the q app it connects to, the listen is apparently successful but in tcpview I don't see a listening connection, instead I see a new connection from the q process to the C++ process. If the C++ app tries to listen on a port that a different q process listens on, the two apps will be listening on the same port. But if the C++ app tries to listen on a non-q app's port, I get the "already in use" error.

Why is this happening? I would expect that the listen should fail if any app is already using that port, but q seems to contradict this rule.

I'm using 3.5 2017.05.02 on Windows 10.

Jack Andrews

unread,
Jun 6, 2017, 12:25:27 AM6/6/17
to Kdb+ Personal Developers
check the interfaces that the two processes are listening on (one can be listening on 127.0.0.1 while the other on 10.1.1.112)

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at https://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.

Flying

unread,
Jun 6, 2017, 5:54:18 AM6/6/17
to Kdb+ Personal Developers
You can have two separate processes listening on the same port, so long as they listen on different IP addresses.

So with the latest q releases, you can do this, too:

// Console 1

// Console 2
q -p 10.0.0.248:8000    # assuming 10.0.0.248 is my LAN IP address
Reply all
Reply to author
Forward
0 new messages