changeset 41:a4bb20871509

add file
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Sun, 29 Apr 2012 19:59:29 +0900
parents 816cdfe3a129
children a942c9855df6
files src/treeVnc/InputStreamTest.java
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/treeVnc/InputStreamTest.java	Sun Apr 29 19:59:29 2012 +0900
@@ -0,0 +1,42 @@
+package treeVnc;
+
+import static org.junit.Assert.*;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.SelectorProvider;
+
+import org.junit.Test;
+
+public class InputStreamTest {
+
+	@Test
+	public void test() {
+		try {
+			bindAddress("localhost",5900);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+		fail("Not yet implemented");
+	}
+	
+	
+	private Socket bindAddress(String host,int port) throws IOException {
+			SocketChannel ssChannel = SelectorProvider.provider().openSocketChannel();
+		try {
+			host = "133.13.58.3";
+			InetSocketAddress address = new InetSocketAddress(host, port);
+			ssChannel.socket().bind(address);
+		} catch (SocketException e) {
+			// for some bad IPv6 implementation
+			ssChannel.socket().bind(new InetSocketAddress(port));
+		}
+		ssChannel.configureBlocking(false);
+		return ssChannel.socket();
+	}
+}