- server
nc -l -vv 12345
- client
echo hello | nc -vv 127.0.0.1 12345
Of course I am going to add some processing between the input and output. This is just a simple example. The IPC is NOT in kdb protocol. Thx.
nc -l -vv 12345
echo hello | nc -vv 127.0.0.1 12345
Of course I am going to add some processing between the input and output. This is just a simple example. The IPC is NOT in kdb protocol. Thx.
Will these allow kdb to speak arbitrary TCP protocol? Thx.
Hello,
The documentation is about how kdb uses the c libraries to listen to a TCP server. Its a one way communication (C server -> KDB client) so it doesn’t support the feature for kdb to communicate back to the server.
Yet, it might be helpful for you to extend this sample to behave like netcat.
Thx. I can now send strings and receive strings like telnet. Below please find the Q code and C code. Is the program limited to making a single outbound tcp connection to a server? Can I abandon the global conn_s handle and return a connection handle from the conn() function?
Now I have made kdb speak a custom protocol as a tcp client. Is it possible to make kdb a tcp server accepting incoming telnet client connections and speak a custom protocol (NOT the kdb ipc protocol)? Thx.
sendString::./echoclntq 2:(
sendString;1)
K sendString(K x) {
if(xn != send(conn_s, kG(x), xn, 0)) {
onerror(“sendString error”);
}
return (K)0;
}
Hey,
You can create more than one socket if needed. As you suggested, you would just need to get rid of the global socket variable and manage the individual handles for each client.
You should also be able to bind a socket to a separate port(non-kdb) and listen for connection as you would in any other C program within kdb. Once you have a client that connects, you can perform any type of communication you would like.
Are there any memory management problems after sending or receiving strings? When should I call r0? Thx.
> separate port(non-kdb)
How can I add protocol support to the kdb port? kdb already speaks kdb-ipc, http, and websocket on the same port. Thx.