Solved

Networkwide events

Posted on 1998-10-16
10
198 Views
Last Modified: 2013-11-20
Does anyone know a really good, fast and safe method to
generate network-wide events with the same handling both
for windows 95 and NT?
Please don't lock the answer as long your method is really
good. The best solution gets the points.
0
Comment
Question by:snoegler
  • 5
  • 4
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1323404
What kind of events are you thinking of?
0
 
LVL 6

Author Comment

by:snoegler
ID: 1323405
>>What kind of events are you thinking of?

Sorry, i forgot to mention this.
I need a fast and easy way to get a single notification. Like the MFC CEvent class - but i need
basically just a simple 'i am set now' notification. Currently this is implemented through a
file object, but this is just for testing purpose. I want to avoid sockets, as they cause some
problems in certain network environments (for example, the ip address of the computer the
application is running on is in some networks not available). Pipes work only with a NT host,
so they are also not what we need.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1323406
So - what about using a simple RPC interface (i'm thinking of RPC callbacks, so it is not _that_ simple...). As it works with all MS network transports (and is easier to handle than DCOM), i'd prefer this method (if you'd like an example on what is possible using this technique, point your browser to 'http://www.proxima.de' and download 'RpcExec').
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Expert Comment

by:Bridge
ID: 1323407
mailslots ??
0
 
LVL 6

Author Comment

by:snoegler
ID: 1323408
To bridge:
Mailslots are a good idea.
But the problem is that they are
- local to the domain in which they were created
- it isn't possible to adress a specific host, they are broadcasted to all machines having a
handle to the mailslot
- most important: it isn't guaranteed that the messages are delivered. It is very important that
the events reach all hosts they are sent to, to keep the integrity of the event structure we need
to implement.

To jkr:
RPC sounds good. DCOM perhaps best fits the requirements, but i don't have any
experience with it yet. I know COM - so maybe this is a starting point.
Can you point me to some information, either a good book or a web page with some docs/
examples ... I would prefer DCOM, but RPC is okay, too.



0
 
LVL 86

Expert Comment

by:jkr
ID: 1323409
Well, if you give me some time (let's say: 2-3h ;-), i'll try to assemble a little sample. By the time, you may want to take a look at the examples on the VC cdrom, especially '\DEVSTUDIO\VC\SAMPLES\SDK\RPC\WHELLO' (so to say, the RPC 'Hello, World!') - though it is not the method i'd use, as with an approach like this an RPC server would have to run on every client that should be notified, i'd like to change it so to say by turning it 180 degrees ;-).
The problem with DCOM is that it has to be configured on every machine and isn't supported by earlier version of Win95, whereas RPC even runs on 16bit Windows...
0
 
LVL 86

Expert Comment

by:jkr
ID: 1323410
OK, here's some example source code for a RPC server that holds a RPC call from a client pending to send notification events by a callback (called 'rpcevent' ;-):

rpcevent.idl:
[ uuid (53D5C102-25F6-11D1-B64C-0000B43A8ACF),
  version(1.0),
  pointer_default(unique)
]
interface RpcEvent
{

unsigned int      ClientEnterNotificationContext      ( [ in] unsigned int      nId);

[ callback]
unsigned int      ClientNotifyEvent            ( [ in, string] unsigned char* pszEventMsg);

void            Shutdown                  (      void);
}

rpcevent.acf:
[ implicit_handle( handle_t RpcEvent_IfHandle)]
interface RpcEvent
{
}

rpcevents.cpp (server):
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>

#include "rpcevent.h" // midl-generated


int main    (   int argc,   char**  argv)
{
    int             nRC;
    RPC_STATUS      rpcRC;
    unsigned char*  pszSecurity =   NULL;
    unsigned int    uMinCalls   =   1;
    unsigned int    uDontWait   =   1;


    rpcRC   =   RpcServerUseProtseqEp   (   g_srvep.pszProtseq,
                                            g_srvep.uMaxCalls,    
                                            g_srvep.pszEndpoint,
                                            pszSecurity
                                        );

    if  (   rpcRC)
        {
            return  (   rpcRC);
        }

    rpcRC   =   RpcServerRegisterIf (   RpcEvent_v1_0_s_ifspec,
                                        NULL,   // MgrTypeUuid
                                        NULL    // MgrEpv; null means use default
                                    );  

    if  (   rpcRC)
        {
            return  (   rpcRC);
        }

    rpcRC   =   RpcServerListen (   uMinCalls,
                                    g_srvep.uMaxCalls,
                                    uDontWait
                                );

    if  (   rpcRC)
        {
            return  (   rpcRC);
        }


    if  (   uDontWait)
        {

            rpcRC   =   RpcMgmtWaitServerListen ();  // wait operation

            if  (   rpcRC)
                {
                    return  (   rpcRC);
                }

        }

    return  (   0);
}


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);
}


unsigned int        ClientEnterNotificationContext      (   unsigned int    nId)
{
    RpcTryExcept
    {
        for (   ;;)
            {
                // wait here until event has to be sent

                ClientNotifyEvent   (   g_pszEvent);
            }
    }
    RpcExcept   (   1)
    {
        ulCode  =   RpcExceptionCode    ();

        if  (   RPC_S_CALL_FAILED_DNE   !=  ulCode)
            {
                TRACE1  (   "RpcEvent:\tRPC exception %d\n",    ulCode);
            }
         else
            {
                TRACE1  (   "RpcEvent:\tclient '%s' disconnected\n",    
                            pClient->acWkSta
                        );

                RpcCancelThread (   GetCurrentThread    ());

                return  (   0);
            }
    }
    RpcEndExcept

    return  (   0);
}


void Shutdown   (   void)
{
    RpcMgmtStopServerListening  (   NULL);
}


NOTE that i just cut this code out of an existing server and modified it for example purposes, i didn't compile it ... ;-)

I'll post the client code later (if you still need it...)


0
 
LVL 6

Author Comment

by:snoegler
ID: 1323411
Thank you very much :)
I think i'll use RPC for now, but i want to go deeper into DCOM.
Just post an answer and i'll give you an A ... but do you have a link to another DCOM
description? I have just browsed through the microsoft site, and found among other information
a freely distributable DCOM95.EXE, which enables all windows 95 versions to support
DCOM. I'll download the DCOM samples there, too. But another link to some interesting
page would be great :)
0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 1323412
Thanx ;-)
Well, MS has the most comprehensive KB about DCOM, and there have been several VERY interesting articles on this in MSJ recently (of course with source code).
Put one problem i was trying to avoid in the solution above will still persist: The clients that should be notified of the events will have to run a server process to be notified... that's not very sophisticated (oops and DCOM callbacks are a bunch of work...) BTW: Just as a performance hint - we use the above method in a license server (nice - if a client crashes it automatically gets unregistered by RPC_E_CALL_FAILED_DNE), and with about 60 connected clients the CPU load of the server machine (NT Wksta test cfg, P133/64MB) increased about 2% <s>...
0
 
LVL 6

Author Comment

by:snoegler
ID: 1323413
Okay, i think RPC has many advantages currently.
Many thanks for your efforts :)
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro to save highlighted rows as a separate file 5 43
sumNumber challenge 16 122
either24  challenge 19 97
ShiftLeft challenge 21 82
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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