• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Networkwide events

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
snoegler
Asked:
snoegler
  • 5
  • 4
1 Solution
 
jkrCommented:
What kind of events are you thinking of?
0
 
snoeglerAuthor Commented:
>>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
 
jkrCommented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
BridgeCommented:
mailslots ??
0
 
snoeglerAuthor Commented:
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
 
jkrCommented:
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
 
jkrCommented:
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
 
snoeglerAuthor Commented:
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
 
jkrCommented:
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
 
snoeglerAuthor Commented:
Okay, i think RPC has many advantages currently.
Many thanks for your efforts :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now