⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vxtimeclient.c

📁 Vxworks的培训教程,大家分享下啊,
💻 C
字号:
/* vxTimeClient.c - RPC client example */#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "rpcLib.h"#include "rpc/rpc.h"#include "time.h"LOCAL CLIENT * pClient;/*************************************************** printTime - print the date and time in a human-* readable format. *    For interactive use from the WindSh shell, * just pass 0 as the second argument ppClient.* For programmatic use, declare a variable of* type CLIENT *, initialize it to NULL, and* pass the address of the variable as the ppClient* argument. The variable will be set to a newly* created CLIENT *, which may be reused in later* calls to printTime by the same task. When the task* has called printTime () for the last time, it should* clean up its CLIENT * with a call to * clnt_destroy().*/STATUS printTime 	(	char * host,	CLIENT ** ppClient	)	{	char **ptr;	if (ppClient == NULL)		{		pClient = NULL;		ppClient = &pClient;		}	/*	 * If *ppClient is NULL, this task has not	 * previously called printTime, and we should	 * initialize RPC support and create a new 	 * client handle for it. Note: it's ok to call	 * rpcTaskInit() more than once for the same	 * task.	 */	if (*ppClient == NULL)		{		if (rpcTaskInit() == ERROR)			{			perror ("rpcTaskInit() failed");			return (ERROR);			}		*ppClient = clnt_create (host, TIME_PROG,										TIME_VERS, "tcp");		if (*ppClient == NULL)			{			perror ("clnt_create failed");			return (ERROR);			}		}	 if ((ptr = print_time_1 (NULL, *ppClient))			== NULL)		{		perror ("print_time_1 failed");		clnt_destroy (*ppClient);		*ppClient = NULL;		return (ERROR);		}	printf (*ptr);	free (*ptr);		/*	 * interactive use: destroy *ppClient.	 * otherwise, caller is responsible.	 */	if (ppClient == &pClient)		clnt_destroy (pClient);	return (OK);	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -