From: Evrim ULU (evrim@envy.com.tr)
Date: Wed 23 Oct 2002 - 11:33:59 EEST
mrb,
rpc ile biraz sorun yasiorum. Anlayan birileri structure'imi return etmem=
e=20
yardimci olursa sevinirim.
[root@drew bridge-rpc]# ./bridge_server &
[1] 10044
[root@drew bridge-rpc]#./bridge_client localhost
Id:1
Host:www.core.gen.tr
Type:1
Id:1224736768
Par=E7alama ar?zas? (core dumped)
[root@drew bridge-rpc]#
(Ps: ilk bolum server tarafindan print edilio. Id:1 .. Id: 122.. die gidi=
n kisim=20
ise client tarafindan basilan)
Saglicakla, kolay gelsin.
--=20
Evrim ULU
evrim@envy.com.tr / evrim@core.gen.tr
sysadm
http://www.core.gen.tr
bridge.x (rpcgen -N -a rpc.x)
--------------------
const MAX_CONFIG =3D 255;
struct _sysmon_config {
int id;
string host<>;
int type;
int port;
int timeout;
string desc<>;
int mail;
};
typedef struct _sysmon_config sysmon_config<MAX_CONFIG>;
program SYSMONCONFIG {
version SYSMON_VERS_1 {
void SYSMON_NULL(void) =3D 0;
void SYSMON_GET_CONFIG(int no) =3D 1;
} =3D 1;
} =3D 400004;
-----------------------
bridge_server.c
--------------
include "bridge.h"
void *
sysmonc_null_1_svc(struct svc_req *rqstp)
{
static char * result;
/*
* insert server code here
*/
return (void *) &result;
}
void *
sysmonc_get_config_1_svc(int no, struct svc_req *rqstp)
{
static char * result;
static struct _sysmon_config gee;
gee.type =3D 1;
gee.host =3D malloc(sizeof(char) *255);
sprintf(gee.host,"www.core.gen.tr");
gee.id =3D 1;
/*
* insert server code here
*/
fprintf(stderr,"Id:%d\nHost:%s\nType:%d\n",gee.id,
gee.host,gee.type);
return (struct _sysmon_config*) &gee;
}
-------------
rpc_client.c
--------------
#include "bridge.h"
void *result_2;
void
sysmonconfig_1(char *host)
{
CLIENT *clnt;
void *result_1;
int sysmon_get_config_1_no;
#ifndef DEBUG
clnt =3D clnt_create (host, SYSMONCONFIG, SYSMON_VERS_1, "udp");=
if (clnt =3D=3D NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
result_1 =3D sysmon_null_1(clnt);
if (result_1 =3D=3D (void *) NULL) {
clnt_perror (clnt, "call failed");
}
result_2 =3D sysmon_get_config_1(sysmon_get_config_1_no, clnt);
if (result_2 =3D=3D (void *) NULL) {
clnt_perror (clnt, "call failed");
}
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
struct _sysmon_config my_config_ptr;
if (argc < 2) {
printf ("usage: %s server_host\n", argv[0]);
exit (1);
}
host =3D argv[1];
sysmonconfig_1 (host);
if (result_2 =3D=3D (struct _sysmon_config *)NULL)
{
fprintf(stderr,"PUCK!\n");
exit (0);
}
memcpy(&my_config_ptr,result_2,sizeof(struct _sysmon_config));
printf("Id:%d\nHost:%s\nType:%d\n",my_config_ptr.id,
my_config_ptr.host,my_config_ptr.type);
}
----------