Solved

RPC / SERVICE SAMPLE CODE - URGENT

Posted on 2000-03-14
5
455 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
ID: 2618305
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
ID: 2620196
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
ID: 2621595
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
ID: 2621635
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
ID: 2621701
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change column content color based on value of "Severity" column 12 55
What are the big features of MVC5? 4 72
Explain Unit of Work pattern 2 55
WPF issue with Trigger 2 94
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

919 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