Solved

Networkwide events

Posted on 1998-10-16
10
195 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
Include multiple hostnames in this command? 3 52
Expand macro to ask for filename column 8 35
zeroMAx challenge 20 76
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

21 Experts available now in Live!

Get 1:1 Help Now