Questions about running the kdb+tick demo

370 views
Skip to first unread message

Xinyu Gai

unread,
Mar 30, 2016, 7:10:03 AM3/30/16
to Kdb+ Personal Developers
Hi,


I'm a bit confused about the code of running the kdb+tick demo on this page: http://code.kx.com/wiki/Startingkdbplus/tick

Under "6.5 running the demo", there is the example code. The code is attached as follows, 

1. tickerplant - the tick.q script defines the tickerplant, and runs on port 5010:

..$ q tick.q -p 5010

2. feed - connects to the tickerplant and sends a new batch every 507 milliseconds:

..$ q feed.q localhost:5010 -t 507

3. rdb - the r.q script defines the real time database:

..$ q tick/r.q -p 5011

4. show - the show process, which does not need a port:

..$ q cx.q show


=====my questions===== 

From my understanding, a new q instance is opened in step 2, and it loads file feed.q and listens on port 5010, is that right? (I'm not sure if "localhost:5010" can be interpreted as "listen on port 5010")

Also what's the difference between "localhost:5010" and "-p 5010"?


the following is the last several lines of code in tick.q. I put my interpretion to the right, could you please correct me if I'm wrong? 
/run
>q tick.q sym  .  -5010   /tick      <-- start a new q instance on port 5010, which is the tickerplant process, and then load tick.q into this q instance.
>q tick/r.q :5010 -5011   /rdb       <-- start a rdb process on port 5011 that listens to port 5010
>q sym            -5012   /hdb       <-- start a hdb process on port 5012
>q tick/ssl.q sym :5010     /feed      <-- start a new q instance that listens to port 5010



Any suggestions and help are appreciated!

Thanks,

Xinyu




Message has been deleted

Enoch Lam

unread,
Mar 30, 2016, 8:29:26 AM3/30/16
to Kdb+ Personal Developers
For the 2nd step

$ q feed.q localhost:5010 -t 507

localhost:5010 is passed into script feed.q, as an argument.

-p command option in Q specifies the listening port number of the started Q session

James Little

unread,
Mar 30, 2016, 8:35:49 AM3/30/16
to Kdb+ Personal Developers
I think it can be interpreted as "connect to localhost:5010" - meaning "connect to the tickerplant". It might not be running on localhost of course, depending on your setup. 

It's a command-line argument to feed.q, rather than the q interpreter itself. Maybe you can see what feed.q is doing with .z.x? http://code.kx.com/wiki/Reference/dotzdotx


On Wednesday, March 30, 2016 at 12:10:03 PM UTC+1, Xinyu Gai wrote:
Hi there,

I am confused about the code in the kdb+tick demo on this page: http://code.kx.com/wiki/Startingkdbplus/tick

Under "6.5 running the demo" there is the example code. I attached  the first two lines as follows,

1. tickerplant - the tick.q script defines the tickerplant, and runs on port 5010:

..$ q tick.q -p 5010

2. feed - connects to the tickerplant and sends a new batch every 507 milliseconds:

..$ q feed.q localhost:5010 -t 507

I am just wondering what is the difference between "-p 5010" and "localhost:5010" ?  As far as i know "-p 5010" will start a tickerplant process on local port 5010. And from my understanding feed




/run
>q tick.q sym  .  -5010   /tick        <--  run tick.q on port 5010
>q tick/r.q :5010 -5011   /rdb         <--  start rdb process on port 5011 and listen to 5010

>q sym            -5012   /hdb

Igor Korkhov

unread,
Mar 30, 2016, 8:35:49 AM3/30/16
to Kdb+ Personal Developers
You are right, q -p 5010 will tell q to listen on port 5010. To be precise, it will tell q to listen on port 5010 on any available interface including loopback aka localhost aka 127.0.0.1. However, you can bind a listening socket to a particular interface if you like. For example, q -p 127.0.0.1:5050 will bind q to loopback interface only, no external client (i.e. from another host) will be able to connect.

On the other hand, localhost:5010 has no meaning to a q process itself, it is just a parameter like for example q foo bar baz. But this parameter tells feed.q where to find the tickerplant, in this case on the same host on port 5010.

When you run the demo the tickerplant will start listening, but feed.q doesn't have to, it merely generates some random data and sends it to the TP.

Does it make sense?
Reply all
Reply to author
Forward
0 new messages