[Spread-users] Dumb Java question

Doug Lee spread at hotzone.com
Mon Sep 23 11:44:18 EDT 2002


I seem to be laboring under a mis-understanding of how this stuff is
supposed to work. I have created simple client and server programs in Java
and have set the server up to join a group with a bogus name ("Spanky").
However it gets all of the messages posted to two different groups
("Archer", "Janeway") by the client regardless. Does this mean that I (the
server) have to look at each message that comes through to check for a
group to which I am interested. If this is the case doesn't this defeat
the purpose? What am I missing here?

[ S E R V E R snippit ]
    SpreadConnection connection = new SpreadConnection();
    connection.connect(InetAddress.getByName(address), port, user,        
                     false, false);
    String privateName = connection.getPrivateGroup().toString();
    SpreadGroup group = new SpreadGroup();
    group.join(connection, "Spanky");
    ...
    in = connection.receive();

[ C L I E N T snippit ]
            SpreadConnection c1 = new SpreadConnection();
	    SpreadConnection c2 = new SpreadConnection();
	    SpreadGroup g1 = new SpreadGroup();
	    SpreadGroup g2 = new SpreadGroup();

            c1.connect(
                InetAddress.getByName(address),
                port, user, true, true);

	    c2.connect(
                InetAddress.getByName(address),
                port, user, true, true);

	    g1.join( c1, "Archer" );
	    g2.join( c2, "Janeway" );

            SpreadMessage out1 = new SpreadMessage();
            SpreadMessage out2 = new SpreadMessage();

            out1.addGroup(g1);
            out2.addGroup(g2);

            for( int i = 0; i < 1000; ++i )
            {
                o1.setMessage( "Starship Enterprise : " + i );
                o2.setMessage( "Starship Voyager : " + i );
                out1.setObject(o1);
                out2.setObject(o2);
                c1.multicast( out1 );
                c2.multicast( out2 );
                ...
            }

Any insight would be helpfull






More information about the Spread-users mailing list