Example usage for java.net SocketException getMessage

List of usage examples for java.net SocketException getMessage

Introduction

In this page you can find the example usage for java.net SocketException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.wso2.bam.integration.tests.hive.BAMJDBCHandlerTestCase.java

@Test(groups = { "wso2.bam" })
public void publishData() {

    String host = null;//from w w w . ja v  a 2s . co m
    try {
        host = getLocalHostAddress().getHostAddress();
    } catch (SocketException e) {
        host = "127.0.0.1";
    }
    try {
        dataPublisher = new DataPublisher("tcp://" + host + ":7611", "admin", "admin");
        defineEventStream();
        publishEvent();
        runHiveDataTypeTest();
        runJDBCHandlerTest();
    } catch (Exception e) {
        fail("Can't get data publisher: " + e.getMessage());
    }

}

From source file:com.monkey.entonado.MainActivity.java

/**
 * Recibe la informacion del servidor con las canciones
 * o cualcquier informacion   `/*from   w w w  . j a v  a  2 s .  co  m*/
 * @return Mensaje
 */
public String recibir() {
    String mensajeRecibir = "";
    try {
        System.out.println("recibiendo canciones metodo recibir");
        String linea = in.readLine();
        if (linea == null) {
            mensajeConexion = "desconectado";
            mensajeRecibir = mensajeConexion;
        }
        System.out.println("-----" + linea + "-----");

        int i = 0;
        while (linea != null && !linea.equals("TERMINO")) {
            i++;
            System.out.println(linea);

            if (linea.split(";").length > 1) {
                String[] lineaSp = linea.split(";");

                if (lineaSp[0].equals(AGREGAR_CANCION)) {
                    String[] infoCancion = lineaSp[1].split(" : ");
                    Cancion cancion = new Cancion(infoCancion[0], infoCancion[1], infoCancion[2]);
                    System.out.println("agrega cancion : " + cancion);
                    canciones.add(cancion);
                } else {
                    mensajeRecibir = lineaSp[1];
                    System.out.println("mensaje no == AGREGAR_CANCION");
                }
            }

            System.out.println("No entro AGREGAR");
            linea = in.readLine();
        }
        System.out.println("linae al final es: " + linea);

        Intent intent = new Intent(this, Resultados.class);
        intent.putParcelableArrayListExtra(EXTRA_CANCIONES, canciones);
        intent.putParcelableArrayListExtra(EXTRA_LISTA, milista);
        startActivityForResult(intent, 999);
    } catch (SocketException e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    } catch (IOException e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    } catch (Exception e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    }
    return mensajeRecibir;
}

From source file:cloud.elasticity.elastman.Sensor.java

public synchronized void addClient(Socket cs) {
    try {/*  ww  w .  j a v a  2s  . c o  m*/
        cs.setSoTimeout(40000); // wait max 40 seconds;
    } catch (SocketException e) {
        log.error("Error: Can't set socket time out!");
        log.error(e.getMessage());
    }
    clientSockets.add(new MyIO(cs));
    log.info("Client added: {}", cs.getInetAddress());
}

From source file:com.google.appinventor.components.runtime.BlockyTalky.java

/**
 * Creates a new BlockyTalky component.//from w w w. j a  v a2s . c  o  m
 */
public BlockyTalky(ComponentContainer container) {
    super(container.$form());
    androidUIHandler = new Handler();

    localBTs = new ConcurrentHashMap<String, LocalBTData>();
    headers = new HashMap<String, String>() {
        {
            put("Sec-WebSocket-Protocol", "echo-protocol");
        }
    };
    handler = new Handler();
    announcerHandler = new Handler();
    Log.d(LOG_TAG, "Done with BlockyTalky constructor.");
    String addr = getIPAddress(true);
    if (addr.equals("")) {
        addr = getIPAddress(false);
    }

    try {
        mContext = container.$context();
        InetAddress ip = InetAddress.getByName(addr); //Android ip
        InetAddress bip = InetAddress.getByName(MULTICAST_ADDRESS);
        ds = new DatagramSocket(UNICAST_PORT);
        //ds.setReuseAddress(true);
        broadcastSocket = new MulticastSocket(MULTICAST_PORT);
        broadcastSocket.joinGroup(bip);
        broadcastSocket.setBroadcast(true);
        MessageListener listener = new MessageListener();
        Thread listenerThread = new Thread(listener);
        listenerThread.start();
        BroadcastListener broadcastListener = new BroadcastListener();
        Thread broadcastThread = new Thread(broadcastListener);
        broadcastThread.start();
        aquireMulticastLock();
        BroadcastAnnouncer announcer = new BroadcastAnnouncer();
        Thread announcerThread = new Thread(announcer);
        announcerThread.start();
    } catch (SocketException e) {
        Log.d(LOG_TAG,
                "Caught SocketException while trying to initialize BlockyTalky messaging: " + e.getMessage());
        e.printStackTrace();
    } catch (UnknownHostException e) {
        Log.d(LOG_TAG, "Caught UnknownHostException while trying to reach Blockytalky messaging router: "
                + e.getMessage());
    } catch (Exception e) {
        Log.d(LOG_TAG, "Exception while initializing BlockyTalky messaging: " + e);
        e.printStackTrace();
    }
    connectToMessagingRouter();

}

From source file:org.lockss.util.urlconn.TestHttpClientUrlConnection.java

public void testNoHttpResponseException() throws Exception {
    client.setExecuteException(new org.apache.commons.httpclient.NoHttpResponseException("Test"));
    try {//ww w. j  a  v  a2 s . com
        conn.execute();
        fail("execute should have thrown SocketException");
    } catch (java.net.SocketException e) {
        // expected
        assertMatchesRE("Connection reset by peer", e.getMessage());
    }
}

From source file:com.arangodb.http.HttpManager.java

/**
 * Executes the request and handles connect exceptions
 * /*from   w  w  w .j a v  a2  s  . c o m*/
 * @param requestEntity
 *            the request
 * @return the response of the request
 * 
 * @throws ArangoException
 */
public HttpResponseEntity execute(HttpRequestEntity requestEntity) throws ArangoException {
    int retries = 0;
    int connectRetryCount = configure.getConnectRetryCount();

    while (true) {
        try {
            return executeInternal(configure.getBaseUrl(), requestEntity);
        } catch (SocketException ex) {
            retries++;
            if (connectRetryCount > 0 && retries > connectRetryCount) {
                logger.error(ex.getMessage(), ex);
                throw new ArangoException(ex);
            }

            if (configure.hasFallbackHost()) {
                configure.changeCurrentHost();
            }

            logger.warn(ex.getMessage(), ex);
            try {
                // 1000 milliseconds is one second.
                Thread.sleep(configure.getConnectRetryWait());
            } catch (InterruptedException iex) {
                Thread.currentThread().interrupt();
            }
        }
    }
}

From source file:org.parosproxy.paros.core.proxy.ProxyThread.java

ProxyThread(ProxyServer server, Socket socket) {
    parentServer = server;// w  ww .ja  v  a 2 s .  c o  m
    proxyParam = parentServer.getProxyParam();
    connectionParam = parentServer.getConnectionParam();

    inSocket = socket;
    try {
        inSocket.setTcpNoDelay(true);
        // ZAP: Set timeout
        inSocket.setSoTimeout(connectionParam.getTimeoutInSecs() * 1000);
    } catch (SocketException e) {
        // ZAP: Log exceptions
        log.warn(e.getMessage(), e);
    }

    thread = new Thread(this, "ZAP-ProxyThread-" + id++); // ZAP: Set the name of the thread.
    thread.setDaemon(true);
    thread.setPriority(Thread.NORM_PRIORITY - 1);
}

From source file:org.apache.tomcat.util.net.PoolTcpEndpoint.java

public void runIt(Object perThrData[]) {

    // Create per-thread cache
    if (endpoint.isRunning()) {
        Socket s = null;// www. j  a v a 2s. c om
        try {
            s = endpoint.acceptSocket();
        } finally {
            // Continue accepting on another thread...
            if (endpoint.isRunning()) {
                endpoint.tp.runIt(this);
            }
        }
        if (null != s) {

            TcpConnection con = null;
            int step = 1;
            try {

                // 1: Set socket options: timeout, linger, etc
                endpoint.setSocketOptions(s);

                // 2: SSL handshake
                step = 2;
                if (endpoint.getServerSocketFactory() != null) {
                    endpoint.getServerSocketFactory().handshake(s);
                }

                // 3: Process the connection
                step = 3;
                con = (TcpConnection) perThrData[0];
                con.setEndpoint(endpoint);
                con.setSocket(s);
                endpoint.getConnectionHandler().processConnection(con, (Object[]) perThrData[1]);

            } catch (SocketException se) {
                endpoint.log
                        .error("Remote Host " + s.getInetAddress() + " SocketException: " + se.getMessage());
                // Try to close the socket
                try {
                    s.close();
                } catch (IOException e) {
                }
            } catch (Throwable t) {
                if (step == 2) {
                    endpoint.log.debug("Handshake failed", t);
                } else {
                    endpoint.log.error("Unexpected error", t);
                }
                // Try to close the socket
                try {
                    s.close();
                } catch (IOException e) {
                }
            } finally {
                if (con != null) {
                    con.recycle();
                }
            }
        }
    }
}

From source file:com.monkey.entonado.MainActivity.java

/**
 * Realiza la conexion al servidor//from ww  w.  j  a  va 2  s  .  c o  m
 * @return mensaje Indica si la conexion fue exitosa
 */
@SuppressLint("NewApi")
public String conectar() {
    intentoConectar = true;
    try {
        System.out.println("Conectado en 4 ");
        canal = new Socket();
        /**
         * Create a client socket with the host,
         * port, and timeout information.
         */
        System.out.println("Conectado en 3");
        canal.bind(null);
        System.out.println("Conectado en 2");
        canal.connect((new InetSocketAddress(ip, 10052)));
        System.out.println("Conectado en 1");
        out = new PrintWriter(canal.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(canal.getInputStream()));

        String info = "";

        AccountManager aManager = AccountManager.get(this);
        Account[] accounts = aManager.getAccountsByType("com.google");

        for (Account account : accounts) {
            String accountId = account.name;
            info += accountId + " : ";
        }

        out.println(INFO_USUARIO + ";" + "U:" + info);

        String mens = in.readLine();

        System.out.println("Estas conectado! " + mens + " : " + canal.getInetAddress());
        mensajeConexion = "Estas conectado!";
        return "Estas Conectado!";
    } catch (SocketException e) {
        System.out.println("No se establecio la conexion");
        mensajeConexion = "No se estableci la conexin: " + e.getMessage();
        return "No se establecio la conexin";
    } catch (Exception e) {
        System.out.println("No se establecio la conexion");
        mensajeConexion = "No se estableci la conexin: " + e.getMessage();
        return "No se establecio la conexin";
    }
}