Java Socket Port getPort(ServerSocket server)

Here you can find the source of getPort(ServerSocket server)

Description

get Port

License

Apache License

Declaration

public static int getPort(ServerSocket server) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;

import java.net.ServerSocket;

public class Main {
    public static int getPort(ServerSocket server) {
        int port = server.getLocalPort();
        try {//w  ww.  ja  v  a 2s  .com
            server.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return port;
    }
}

Related

  1. getFreeSocketPort()
  2. getHostPort(Socket s)
  3. getMyPortNumber(ServerSocket serverSocket)
  4. getRandomPortServerSocket()
  5. getServerSocket(int i_Port)
  6. isValidSocket(String host, int port)
  7. releasePort(ServerSocket ss)