Questions about running the kdb+tick demo

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  .  -p 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 -p 5011   /rdb       <– start a rdb process on port 5011 that listens to port 5010
>q sym            -p 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

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?

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

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

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

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

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

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

  1. 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  .  -p 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 -p 5011   /rdb       <– start a rdb process on port 5011 that listens to port 5010
>q sym            -p 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

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