Solved

RPC / SERVICE SAMPLE CODE - URGENT

Posted on 2000-03-14
5
453 Views
Last Modified: 2013-12-03
Experts,
i can't download the source code for rpc and service programs from the msdn,
i need a simple code (a hello world rpc/service applications), it's necessary the idl interface too.

thanks
0
Comment
Question by:cvillacrizv
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
Comment Utility
Run server srv.exe
Run
 cli.exe localhost "Hello, World!"

To shutdown server,

   cli.exe localhost SHUTDOWN

--- make.bat
-----------------------------
midl hello.idl
cl srv.c hello_s.c rpcrt4.lib
cl cli.c hello_c.c rpcrt4.lib


--- cli.c
-----------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "hello.h"

void main(int argc, char *argv[])
{
    unsigned char *pszStringBinding;

    if (argc != 3)
    {
        printf("Usage: %s hostname string-to-print\n", argv[0]);
        exit(1);
    }
    RpcStringBindingCompose(NULL, "ncacn_ip_tcp", argv[1], "8000", NULL,
&pszStringBinding);
    RpcBindingFromStringBinding(pszStringBinding, &hello_IfHandle);
    if (strcmp(argv[2], "SHUTDOWN")) HelloProc(argv[2]);
    else Shutdown();
    RpcStringFree(&pszStringBinding);
    RpcBindingFree(&hello_IfHandle);
}

void  __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
    return(malloc(len));
}
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
    free(ptr);
}

--------- srv.c
-----------------------------

#include <stdlib.h>
#include <stdio.h>
#include "hello.h"

void HelloProc(const unsigned char *pszString)
{
    printf("%s\n", pszString);
}

void Shutdown(void)
{
    RpcMgmtStopServerListening(NULL);
    RpcServerUnregisterIf(NULL, NULL, FALSE);
}

void main(int argc, char * argv[])
{
    RpcServerUseProtseqEp("ncacn_ip_tcp", 20, "8000", NULL);
    RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL);
    RpcServerListen(1, 20, FALSE);
}

void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
    return(malloc(len));
}

void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
    free(ptr);
}

--------hello.acf
-----------------------------
[
  implicit_handle(handle_t hello_IfHandle)
]
interface hello
{
}


--------hello.idl
-----------------------------
[
  uuid (6fdd2ce0-0985-11cf-87c3-00403321bfac),
  version(1.0)
]
interface hello
{
  void HelloProc([in, string] const unsigned char *pszString);
  void Shutdown(void);
}

0
 
LVL 1

Author Comment

by:cvillacrizv
Comment Utility
Thanks NickRepin i have compiled and  tested the samples and it works!

Finally, i need this source to be a nt service, please i need some simple guide to convert the rpc sample into a nt service/rpc sample...
0
 
LVL 15

Expert Comment

by:NickRepin
Comment Utility
Sorry, that is totally different from your original question.

I'm afraid, when I answer to your new question, you'll ask me again about something else.



0
 
LVL 1

Author Comment

by:cvillacrizv
Comment Utility
NickRepin,
i' very sorry, i'll try to be more specific in the future.

Thanks for your help
0
 
LVL 15

Expert Comment

by:NickRepin
Comment Utility
Thank you,

but the service/rpc sample is really several times harder than just rpc.
I have no time at the moment to write it for you. Sorry.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now