This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sunrpc: svc_register failed (Cygwin general on W2K)


Hello!

I've a problem with RPC. I tried a very simple RPC-example from web (a
message server) for understanding how the stuff goes (I've never progammed
rpc before), but I always get this error message at svc_register when I
start the server:

Cannot register service: RPC: Unable to receive; errno = Connection reset by
peer

I've administrator rights on the machine (Windows 2000 Professional SP4) and
the RPC service is running. Cygwin sunrpc-package is installed.

Does anybody have a hint?

Thanks!

Thomas Kusch
thkusch@epost.de


Here are the sources of the server 
(compiled with gcc msg_svc.c msg_proc.c -lrpclib)
---------------msg_svc.c-----------------
#include <stdio.h>
#include <rpc/rpc.h>
#include "msg.h"

static void messageprog_1();

main()
{
	SVCXPRT *transp;

	(void)pmap_unset(MESSAGEPROG, PRINTMESSAGEVERSION);

	transp = svcudp_create(RPC_ANYSOCK);
	if (transp == NULL) exit(1);
	
	if (!svc_register(transp, MESSAGEPROG, PRINTMESSAGEVERSION, messageprog_1,
IPPROTO_UDP)) exit(1);	

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) exit(1);
		
	if (!svc_register(transp, MESSAGEPROG, PRINTMESSAGEVERSION, messageprog_1,
IPPROTO_TCP)) exit(1);
	
	svc_run();	
	exit(1);
}

static void
messageprog_1(rqstp, transp)
	struct svc_req *rqstp;
	SVCXPRT *transp;
{
	union {
		char *printmessage_1_arg;
	} argument;
	char *result;
	bool_t (*xdr_argument)(), (*xdr_result)();
	char *(*local)();

	switch (rqstp->rq_proc) {
	case NULLPROC:
		(void)svc_sendreply(transp, xdr_void, (char *)NULL);
		return;

	case PRINTMESSAGE:
		xdr_argument = xdr_wrapstring;
		xdr_result = xdr_int;
		local = (char *(*)()) printmessage_1;
		break;

	default:
		svcerr_noproc(transp);
		return;
	}
	bzero((char *)&argument, sizeof(argument));
	if (!svc_getargs(transp, xdr_argument, &argument)) {
		svcerr_decode(transp);
		return;
	}
	result = (*local)(&argument, rqstp);
	if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
		svcerr_systemerr(transp);
	}
	if (!svc_freeargs(transp, xdr_argument, &argument)) exit(1);	
}

----------------------------------------

---------------msg.h--------------------
#define MESSAGEPROG ((u_long)0x20000001)
#define PRINTMESSAGEVERSION ((u_long)1)
#define PRINTMESSAGE ((u_long)1)
extern int *printmessage_1(); 
----------------------------------------


------------msg_proc.c-----------------
#include <stdio.h>
#include "msg.h"

int * printmessage_1( char ** msg, struct svc_req * req)
{
    FILE *f;
    static int result;

    f = fopen("/rpctut1.txt","a");

    if (f == (FILE *) NULL) {
	result = 0;
	return(&result);
    }
    fprintf(f,"%s\n",*msg);
    fclose(f);
    result = 1;
    return(&result);
} 
-----------------------------------------

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]