Here you can find the source of getSocketFromString(String s)
public static Socket getSocketFromString(String s) throws UnknownHostException, IOException
//package com.java2s; //License from project: LGPL import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; public class Main { public static Socket getSocketFromString(String s) throws UnknownHostException, IOException { Socket result = null;/*from www . j a v a2s . c om*/ String[] splitAddress = s.split(":"); if (splitAddress.length > 1) { String hostname = splitAddress[0]; int port = Integer.parseInt(splitAddress[1]); result = new Socket(hostname, port); } return result; } }