Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

FastmsgTransport.cc

Go to the documentation of this file.
00001 /**************************************************************************
00002  Copyright (c) 2000-2001, Tony Garnock-Jones
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without
00006  modification, are permitted provided that the following conditions are
00007  met:
00008 
00009      * Redistributions of source code must retain the above copyright
00010        notice, this list of conditions and the following disclaimer.
00011 
00012      * Redistributions in binary form must reproduce the above
00013        copyright notice, this list of conditions and the following
00014        disclaimer in the documentation and/or other materials provided
00015        with the distribution.
00016 
00017      * Neither the names of the copyright holders nor the names of this
00018        software's contributors may be used to endorse or promote
00019        products derived from this software without specific prior
00020        written permission.
00021 
00022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
00026  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 **************************************************************************/
00034 
00035 #include <stdlib.h>
00036 #include <stdio.h>
00037 #include <string.h>
00038 #include <assert.h>
00039 #include <errno.h>
00040 
00041 #include <sys/types.h>
00042 #include <sys/socket.h>
00043 #include <netdb.h>
00044 #include <netinet/in.h>
00045 #include <unistd.h>
00046 #include <fcntl.h>
00047 
00048 #include <mps/mps.h>
00049 #include <mps/transport_fastmsg.h>
00050 
00051 #include "FastmsgLink.h"
00052 #include "FastmsgServer.h"
00053 
00054 #include <map>
00055 #include <utility>
00056 #include <string>
00057 
00058 namespace MPS {
00059 
00060 FastmsgTransport *FastmsgTransport::instance = 0;
00061 
00062 FastmsgTransport::FastmsgTransport(Scheduler &s)
00063   : Transport("fastmsg"),
00064     sched(s)
00065 {}
00066 
00067 ref<Connection> FastmsgTransport::connectTo(Address const &spec) {
00068   if (spec.getParamCount() != 1)
00069     throw MPSException("Incorrect parameter count in Address to FastmsgTransport");
00070 
00071   return new FastmsgLink(spec.getParam(0), spec);
00072 }
00073 
00074 string FastmsgTransport::registerServer(Server *server, Address const &spec) {
00075   string oid = server->getObjectName();
00076   char sockName[32];
00077 
00078   sprintf(sockName, "mps2_%d", (int) getpid());
00079   sched.spawn(new MailboxThread(sched,
00080                                 Mailbox::create(oid.c_str()),
00081                                 new FastmsgServerFactory(server),
00082                                 sockName));
00083 
00084   return string("mps:fastmsg:") + oid;
00085 }
00086 
00087 string FastmsgTransport::deregisterServer(Server *server, Address const &spec) {
00088   // how embarrassing.
00089   throw MPSException("FastmsgTransport::deregisterServer not yet implemented");
00090 }
00091 
00092 }

Generated at Wed Aug 15 01:05:15 2001 for mps-cpp by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001