libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

nc_connect_inout

Open kpbarrett opened this issue 7 years ago • 2 comments

Is anybody using this or can provide an example of how to use? Or tell me if I'm using it inappropriately. I am trying to establish a NETCONF session between a server and a client on the same machine.

In my client, when I replace a working SSH connect:

    s = nc_connect_ssh("localhost", 0, NULL);

with:

    int sock[2];
    socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
    s = nc_connect_inout(sock[0], sock[1], NULL);

NULL is returned and libnetconf2 reports: Missing <session-id> in server's <hello>. Debug logging seems to show messages flowing in both directions, it just looks like the server reply fails validation. Any information is appreciated. Thanks,

-- Kevin

kpbarrett avatar Sep 19 '18 19:09 kpbarrett

Hi Kevin, you always need both a client and a server. You effectively made a client talk with itself so it reads weird messages, naturally. You want to pass one socket for both input and output of nc_connect_inout and another for both input and output of nc_accept_inout (server-side).

Regards, Michal

michalvasko avatar Sep 20 '18 06:09 michalvasko

Got it. Thanks!

-- Kevin

kpbarrett avatar Sep 20 '18 11:09 kpbarrett