Java Socket Create getSocket(String host, int port, int timeout)

Here you can find the source of getSocket(String host, int port, int timeout)

Description

get Socket

License

Open Source License

Declaration

public static Socket getSocket(String host, int port, int timeout) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-3.0-standalone.html
 ******************************************************************************/

import java.io.IOException;

import java.net.InetSocketAddress;

import java.net.Socket;
import java.net.SocketAddress;

public class Main {
    public static Socket getSocket(String host, int port, int timeout) throws IOException {
        SocketAddress sockaddr = new InetSocketAddress(host, port);
        Socket socket = new Socket();
        socket.connect(sockaddr, timeout);

        return socket;
    }/*from  ww  w  .j a  va 2 s .co  m*/
}

Related

  1. createSocketAddrForHost(String hostName, int port)
  2. createSocketServer(int port)
  3. getSocket()
  4. getSocket(String host, int port)
  5. getSocket(String host, int port)
  6. getSocket(String i_HostName, int i_Port)
  7. getSocketFromString(String s)
  8. getSocketId(Socket socket)
  9. getSocketInRange(int minPort, int maxPort, boolean random)