Solved

RPC / SERVICE SAMPLE CODE - URGENT

Posted on 2000-03-14
5
460 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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