diff options
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r-- | libvxi11client/libvxi11client.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 6234c0f..e814fdf 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -1,6 +1,15 @@ #include <stdbool.h> +#include <rpc/rpc.h> +#include <netinet/in.h> #include "vxi11.h" +#define DEBUG + +#ifdef DEBUG +#include <stdio.h> +#include <arpa/inet.h> +#endif + /** * This is a thin wrapper around the rpcgen generated code to give it a simpler interface. * Only one server with a single link is supported. @@ -13,6 +22,7 @@ #define VXI11_DEFAULT_TIMEOUT 1000 static CLIENT* clnt = NULL; +static CLIENT* abortclnt = NULL; static Device_Link link; static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset) { @@ -33,6 +43,7 @@ static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset int vxi11_open(char* address, char* device) { clnt = clnt_create(address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp"); + if (clnt == NULL) return 0; @@ -46,6 +57,30 @@ int vxi11_open(char* address, char* device) { Create_LinkResp* linkresp = create_link_1(&link_parms, clnt); if (linkresp != NULL && linkresp->error == 0) { link = linkresp->lid; + +#ifdef DEBUG + printf("Link created, abort channel port %d\n", linkresp->abortPort); +#endif + + struct sockaddr_in serveraddr; + if (clnt_control(clnt, CLGET_SERVER_ADDR, (char*) &serveraddr)) { + +#ifdef DEBUG + char addressstring[INET_ADDRSTRLEN]; + *inet_ntop(AF_INET, &serveraddr.sin_addr, addressstring, sizeof(addressstring)); + printf("Remote is %s\n", addressstring); +#endif + + int sock = RPC_ANYSOCK; + abortclnt = clnttcp_create(&serveraddr, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, &sock, 0, 0); + if (abortclnt == NULL) + return 0; + + } + else + // failed! + return 0; + return 1; } else if (linkresp == NULL) @@ -286,7 +321,7 @@ int vxi11_destroy_intr_chan() { */ int vxi11_abort() { - if (clnt == NULL) + if (abortclnt == NULL) return 0; Device_Error* error = device_abort_1(&link, clnt); if (error != NULL && error->error == 0) |