FileDocCategorySizeDatePackage
SocketChannelCreate.javaAPI DocExample890Tue Jan 22 12:09:28 GMT 2002com.ronsoft.books.nio.channels

SocketChannelCreate

public class SocketChannelCreate extends Object
Test creation of SocketChannels. Created and tested: Dec 31, 2001
author
Ron Hitchens (ron@ronsoft.com)
version
$Id: SocketChannelCreate.java,v 1.1 2002/01/22 21:09:28 ron Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		SocketChannel sc;
		Socket sock;

		sc = SocketChannel.open();
		sock = sc.socket();

		print ("SocketChannel.open()", sc, sock);

		sock = new Socket();
		sc = sock.getChannel();

		print ("SocketChannel.open()", sc, sock);
	
private static voidprint(java.lang.String msg, java.nio.channels.SocketChannel sc, java.net.Socket sock)

		boolean hasChannel = (sc != null);
		boolean hasSocket = (sock != null);

		System.out.println (msg + ": channel=" + hasChannel
			+ ", socket=" + hasSocket);