Here you can find the source of createServerSocketChannel(int aPort, String aHostname)
Parameter | Description |
---|---|
aPort | a parameter |
aHostname | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static ServerSocketChannel createServerSocketChannel(int aPort, String aHostname) throws IOException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.ServerSocketChannel; public class Main { /**/* www. j a v a 2 s . c o m*/ * Creates a ServerSocketChannel * * @param aPort * @param aHostname * @return The ServerSocketChannel instance * @throws IOException */ public static ServerSocketChannel createServerSocketChannel(int aPort, String aHostname) throws IOException { ServerSocketChannel lServer = ServerSocketChannel.open(); lServer.configureBlocking(false); if (null == aHostname) { lServer.socket().bind(new InetSocketAddress(aPort)); } else { lServer.socket().bind( new InetSocketAddress(InetAddress.getByName(aHostname), aPort)); } return lServer; } }