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

x
?
Solved

Networkwide events

Posted on 1998-10-16
10
Medium Priority
?
214 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 800 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

876 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