delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/06/07/05:25:41

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 7 Jun 2004 11:25:33 +0200 (MEST)
From: "Thomas Kusch" <th_kusch AT gmx DOT net>
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
References: <1086598778 DOT 19034 DOT ezmlm AT cygwin DOT com>
Subject: sunrpc: svc_register failed (Cygwin general on W2K)
X-Authenticated: #878311
Message-ID: <2394.1086600333@www19.gmx.net>
X-Flags: 0001
X-IsSubscribed: yes

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 AT epost DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019