# Opening a network connection

**URL:** <https://forum.kx.com/t/opening-a-network-connection/8238>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [May 3, 2013, 2:05am UTC](https://forum.kx.com/t/opening-a-network-connection/8238 "2013-05-03T02:05:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Wong1](https://avatars.discourse-cdn.com/v4/letter/v/b77776/32.png) [@Victor\_Wong1](https://forum.kx.com/u/Victor_Wong1)\
**Post date:** [May 3, 2013, 2:05am UTC](https://forum.kx.com/t/opening-a-network-connection/8238/1 "2013-05-03T02:05:00Z")

</div>

I understand that hopen opens either a file or an IPC connection to another kdb process. &nbsp;Is there any way to open a simple character connection to a network host, ala telnet? &nbsp;I also saw that one could use the following syntax: `:[http://hostname](http://hostname) “GET x” to open a character connection and retrieve a response (in this case HTML from a HTTP server), but I don’t know if there is a different syntax to keep the connection open? &nbsp;I am trying to open a session with a server that speaks a simple textual protocol and would prefer to do it in q.

Thanks in advance,

Victor

---

<div class="post-metadata">

**Author:** ![Victor\_Wong1](https://avatars.discourse-cdn.com/v4/letter/v/b77776/32.png) [@Victor\_Wong1](https://forum.kx.com/u/Victor_Wong1)\
**Post date:** [May 3, 2013, 5:40am UTC](https://forum.kx.com/t/opening-a-network-connection/8238/2 "2013-05-03T05:40:00Z")

</div>

Thanks, John. &nbsp;I am actually not trying to connect to another kdb process, but to a server that uses a textual protocol, like HTTP or SMTP (for example). &nbsp;Conceptually, it’s basically the same as sending strings synchronously back and forth like in your example, except without the serialization.

---

<div class="post-metadata">

**Author:** ![Ryan\_Hamilton1](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@Ryan\_Hamilton1](https://forum.kx.com/u/Ryan_Hamilton1)\
**Post date:** [May 3, 2013, 11:11am UTC](https://forum.kx.com/t/opening-a-network-connection/8238/3 "2013-05-03T11:11:00Z")

</div>

Hi Victor,

I think your only option for a constantly open connection is to extend kdb with some C code. The rserve code allows connecting and sending text commands to an R server from within q, it may be useful to look at.  
http://code.kx.com/wsvn/code/cookbook\_code/r/rserve/

If you just wanted to synchronously download some data, you could use a command line tool from within q to download it to file, then read the file.

Regards,  
Ryan

On 5/3/2013 5:40 AM, Victor Wong wrote:

> Thanks, John. &nbsp;I am actually not trying to connect to another kdb process, but to a server that uses a textual protocol, like HTTP or SMTP (for example). &nbsp;Conceptually, it’s basically the same as sending strings synchronously back and forth like in your example, except without the serialization.
> 
> On Thursday, May 2, 2013 6:13:47 PM UTC-7, John Dempster wrote:
> 
> > You can send strings of commands using the handle hopen returns.
> > 
> > See the IPC example video here&nbsp;http://www.timestored.com/kdb-guides/interprocess-communication
> > 
> > ~JD
> > 
> > On Friday, May 3, 2013 2:05:51 AM UTC+1, Victor Wong wrote:
> > 
> > > I understand that hopen opens either a file or an IPC connection to another kdb process. &nbsp;Is there any way to open a simple character connection to a network host, ala telnet? &nbsp;I also saw that one could use the following syntax: `:http://hostname “GET x” to open a character connection and retrieve a response (in this case HTML from a HTTP server), but I don’t know if there is a different syntax to keep the connection open? &nbsp;I am trying to open a session with a server that speaks a simple textual protocol and would prefer to do it in q.
> > > 
> > > Thanks in advance,
> > > 
> > > Victor
> 
> –  
> 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 http://groups.google.com/group/personal-kdbplus?hl=en.  
> For more options, visit https://groups.google.com/groups/opt\_out.  
> &nbsp;  
> &nbsp;

```
-- 

```

[TimeStored.com](http://TimeStored.com) - KDB+ Training, Consulting, Software

---

<div class="post-metadata">

**Author:** ![WooiKent\_Lee](https://avatars.discourse-cdn.com/v4/letter/w/5f8ce5/32.png) [@WooiKent\_Lee](https://forum.kx.com/u/WooiKent_Lee)\
**Post date:** [May 3, 2013, 1:23pm UTC](https://forum.kx.com/t/opening-a-network-connection/8238/4 "2013-05-03T13:23:00Z")

</div>

You can look about here:

http://code.kx.com/wsvn/code/contrib/rpairceir/KDB%20TCP/?#af1754533edd3a736885f54cb836c52b3

Just a simple code where a C based TCP data feeder sending random strings to a q session.&nbsp;Hopefully it can help you though.
