Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RPC / SERVICE SAMPLE CODE - URGENT

Posted on 2000-03-14
5
Medium Priority
?
492 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 400 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

885 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