Skip to content

Instantly share code, notes, and snippets.

@cdecker
Created February 22, 2011 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdecker/839395 to your computer and use it in GitHub Desktop.
Save cdecker/839395 to your computer and use it in GitHub Desktop.
/**
* Copyright 2011 Christian Decker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part the BitDroidMonitor Project.
*/
package net.bitdroid.monitor;
import java.io.IOException;
import java.net.InetAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.bitdroid.network.BitcoinEventListener;
import net.bitdroid.network.Event;
import net.bitdroid.network.NonBlockingBitcoinReactorNetwork;
import net.bitdroid.network.PoolMaintainerListener;
import net.bitdroid.network.messages.PeerAddress;
/**
* @author cdecker
*
*/
public class BitcoinMultiConnectionTest {
private static Logger log = LoggerFactory.getLogger(BitcoinMultiConnectionTest.class);
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
NonBlockingBitcoinReactorNetwork reactor = new NonBlockingBitcoinReactorNetwork(8334);
reactor.addListener(new BitcoinEventListener() {
public void eventReceived(Event event) {
log.info("Received: {} of type {}", event.getSubject(), event.getType());
}
public void messageSent(Event event) {
log.info("Sent: {} of type {}", event.getSubject(), event.getType());
}
});
//reactor.addListener(new PoolMaintainerListener(reactor));
PeerAddress a = new PeerAddress();
a.setAddress(InetAddress.getByName("localhost"));
a.setPort(8333);
//reactor.connect(a);
reactor.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment