diff options
author | daniel <danieruru@gmail.com> | 2013-01-10 17:56:04 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-10 17:56:04 +0900 |
commit | bd451ce0f4855bc2dfd8c19b1f17a5cd60eb6650 (patch) | |
tree | a3a739c7e70bbf9473af42217ee7e911f810df99 | |
parent | 54329a7c7f740171d1594c6c6195277c2924f31f (diff) |
add some more code to the server side
-rw-r--r-- | libvxi11client/client.c | 4 | ||||
-rw-r--r-- | vxi11_server.c | 32 |
2 files changed, 32 insertions, 4 deletions
diff --git a/libvxi11client/client.c b/libvxi11client/client.c index 9656e4d..bc8a49f 100644 --- a/libvxi11client/client.c +++ b/libvxi11client/client.c @@ -10,6 +10,8 @@ static char* geterrorstring(int errorcode) { return "invalid state (not connected) or no response from server"; case -4: return "invalid link identifier"; + case -6: + return "channel not established"; case -8: return "operation not supported"; case -11: @@ -126,7 +128,7 @@ int main(int argc, char *argv[]) { // create interrupt channel printf("-- Testing interrupt channel --\n"); - if ((err = vxi11_create_intr_chan() > 0)) { + if ((err = vxi11_create_intr_chan()) > 0) { printf("Created interrupt channel\n"); // destroy interrupt channel if ((err = vxi11_destroy_intr_chan()) > 0) diff --git a/vxi11_server.c b/vxi11_server.c index 906613f..06a8c44 100644 --- a/vxi11_server.c +++ b/vxi11_server.c @@ -224,15 +224,41 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) { printf("Client %s is asking for an interrupt connection on port %u\n", clientaddressstring, ntohs(argp->hostPort)); #endif - result.error = 0; + bool alreadyhavechannel = false; + if (alreadyhavechannel) { + result.error = ERR_CHANNELALREADYESTABLISHED; + } + else { + struct sockaddr_in clientaddr; + clientaddr.sin_family = AF_INET; + clientaddr.sin_port = argp->hostPort; + clientaddr.sin_addr.s_addr = argp->hostAddr; + int sock = RPC_ANYSOCK; + CLIENT* clnt = clnttcp_create(&clientaddr, DEVICE_INTR, DEVICE_INTR_VERSION, &sock, 0, 0); + if (clnt == NULL) { +#ifdef DEBUG + printf("Couldn't create interrupt channel client\n"); +#endif + result.error = ERR_CHANNELNOTESTABLISHED; + } + else { + result.error = 0; + } + } return &result; } Device_Error * destroy_intr_chan_1_svc(void *argp, struct svc_req *rqstp) { - printf("destroy_intr_chan_1_svc()\n"); static Device_Error result; - result.error = 0; + printf("destroy_intr_chan_1_svc()\n"); + bool havechannel = false; + if (!havechannel) { + result.error = ERR_CHANNELNOTESTABLISHED; + } + else { + result.error = 0; + } return &result; } |