# h: hopen \`::5000;  connection to a port

**URL:** <https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [February 2, 2016, 4:06pm UTC](https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766 "2016-02-02T16:06:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![badaouisaad](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@badaouisaad](https://forum.kx.com/u/badaouisaad)\
**Post date:** [February 2, 2016, 4:06pm UTC](https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766/1 "2016-02-02T16:06:00Z")

</div>

Dear All,

I stored some data in port 5000.

When I try to read it from another command window i do:

(1)&nbsp;h: hopen `::5000;

(2) h" select from table where date= , time\>="

(3) close the connection using hclose h

However, I have made a mistake at point 3) &nbsp;instead of using “hclose h” I used &nbsp;“h(close,0)”;

Then when I try to reconnect to p 5000 (or any other ports -say p 5010) i get an error like “hop: No connection could be made because the target machine actively refused it.”

How can I re-establish a connection with a port? Why am I getting this error?

Thanks a lot for your help

S

---

<div class="post-metadata">

**Author:** ![yogeshg91](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@yogeshg91](https://forum.kx.com/u/yogeshg91)\
**Post date:** [February 2, 2016, 5:29pm UTC](https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766/2 "2016-02-02T17:29:00Z")

</div>

I couldn’t reproduce the error. Following is my attempt

Yogeshs-MacBook-Pro:Resume yogeshgarg$ q -p 20301  
q)  
q).yo.a : 1  
q)

Yogeshs-MacBook-Pro:Resume yogeshgarg$ q  
q)  
q)`::20301(get;`.yo.a )&nbsp;&nbsp;&nbsp;&nbsp; // I’d rather use this for one-time queries  
1  
q)  
q)h: hopen `::20301 q)h(get;`.yo.a)  
1  
q)h(close,0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Throws an error that says close is not a valid symbol  
'close  
q)h(get;`.yo.a) 1 q)h(close;0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Again, as expected 'close q)h(get;`.yo.a)  
1

I suspect the problem is unrelated. Have you tried turning it off and on again? :P

**Yogesh Garg**

---

<div class="post-metadata">

**Author:** ![kuentang](https://avatars.discourse-cdn.com/v4/letter/k/bc8723/32.png) [@kuentang](https://forum.kx.com/u/kuentang)\
**Post date:** [February 3, 2016, 7:48am UTC](https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766/3 "2016-02-03T07:48:00Z")

</div>

Cant reproduce it either.\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

Kim\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

**Von:** [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com) [[mailto:personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com)] **Im Auftrag von** yogesh garg  
**Gesendet:** Dienstag, 2. Februar 2016 18:29  
**An:** [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com)  
**Betreff:** Re: [personal kdb+] h: hopen `::5000; connection to a port\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

I couldn’t reproduce the error. Following is my attempt

Yogeshs-MacBook-Pro:Resume yogeshgarg$ q -p 20301  
q)  
q).yo.a : 1  
q)

Yogeshs-MacBook-Pro:Resume yogeshgarg$ q  
q)  
q)`::20301(get;`.yo.a )&nbsp;&nbsp;&nbsp;&nbsp; // I’d rather use this for one-time queries  
1  
q)  
q)h: hopen `::20301 q)h(get;`.yo.a)  
1  
q)h(close,0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Throws an error that says close is not a valid symbol  
'close  
q)h(get;`.yo.a) 1 q)h(close;0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Again, as expected 'close q)h(get;`.yo.a)  
1

\<o:p\>\</o:p\>

I suspect the problem is unrelated. Have you tried turning it off and on again? :P\<o:p\>\</o:p\>

\<o:p\>\</o:p\>

**Yogesh Garg** \<o:p\>\</o:p\>

\<o:p\> \</o:p\>

\<o:p\> \</o:p\>

On 2 February 2016 at 21:36, Saad Badaoui \<badaouisaad@gmail.com\> wrote:\<o:p\>\</o:p\>

Dear All,\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

I stored some data in port 5000.\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

When I try to read it from another command window i do:\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

(1)&nbsp;h: hopen `::5000;\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

(2) h" select from table where date= , time\>="\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

(3) close the connection using hclose h\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

However, I have made a mistake at point 3) &nbsp;instead of using “hclose h” I used &nbsp;“h(close,0)”;\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

Then when I try to reconnect to p 5000 (or any other ports -say p 5010) i get an error like “hop: No connection could be made because the target machine actively refused it.”\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

How can I re-establish a connection with a port? Why am I getting this error?\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

Thanks a lot for your help\<o:p\>\</o:p\>

\<o:p\> \</o:p\>

S\<o:p\>\</o:p\>

–  
Submitted via Google Groups

---

<div class="post-metadata">

**Author:** ![badaouisaad](https://avatars.discourse-cdn.com/v4/letter/b/d6d6ee/32.png) [@badaouisaad](https://forum.kx.com/u/badaouisaad)\
**Post date:** [February 3, 2016, 8:33am UTC](https://forum.kx.com/t/h-hopen-5000-connection-to-a-port/10766/4 "2016-02-03T08:33:00Z")

</div>

Thanks Yogesh. I think i closed the port instead of just closing the connection to the port. &nbsp;So when I reconnect to the port it is does not recognize it. I think thats what happened

Many Thanks
