Here you can find the source of getSocket(String i_HostName, int i_Port)
public final static Socket getSocket(String i_HostName, int i_Port)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.Socket; public class Main { public final static Socket getSocket(String i_HostName, int i_Port) { if (i_Port <= 0 || i_Port > 65535) { throw new IndexOutOfBoundsException("Port isn't between 0 and 65535."); }// w w w.ja va 2 s . com Socket v_Ret = null; try { InetAddress v_InetAddress = InetAddress.getByName(i_HostName); if (v_InetAddress != null) { v_Ret = new Socket(v_InetAddress, i_Port); } } catch (Exception exce) { v_Ret = null; } return v_Ret; } }