List of usage examples for java.net SocketException SocketException
public SocketException(String msg)
From source file:org.kawanfw.file.api.util.client.ExceptionThrower.java
/** * Allows to simulation an Exception on chunk uplaod in order to test the * recovery mechanism// w w w . j a v a 2 s. co m * * @throws IOException */ public static void throwSocketExceptionIfFlagFileExists() throws IOException { { File flagFile = new File(FrameworkFileUtil.getUserHomeDotKawansoftDir() + File.separator + "throwSocketExceptionFlag.txt"); if (flagFile.exists()) { // Slow down all for our tests try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } String content = FileUtils.readFileToString(flagFile); if (content.contains("1")) { FileUtils.write(flagFile, "2"); throw new SocketException( "Exception simulation on upload(): " + flagFile + " exists and contains 1"); } } } }
From source file:org.pouzinsociety.socket.tcp.SocketClient.java
public SocketClient(TransportLayer tcpTransport, StackConfiguration stackConfiguration) throws SocketException { this.tcpTransport = tcpTransport; this.stackConfiguration = stackConfiguration; if (stackConfiguration.Complete()) new Thread(this).start(); else//from w ww . j av a2s . c om throw new SocketException("StackConfiguration not complete"); }
From source file:org.pouzinsociety.socket.tcp.SocketServer.java
public SocketServer(TransportLayer tcpTransport, StackConfiguration stackConfiguration) throws SocketException { this.tcpTransport = tcpTransport; this.stackConfiguration = stackConfiguration; if (stackConfiguration.Complete()) new Thread(this).start(); else//from w ww . j ava2s.c om throw new SocketException("StackConfiguration not complete"); }
From source file:org.pouzinsociety.socket.udp.SocketClient.java
public SocketClient(TransportLayer udpTransport, StackConfiguration stackConfiguration) throws SocketException { this.udpTransport = udpTransport; this.stackConfiguration = stackConfiguration; if (stackConfiguration.Complete()) new Thread(this).start(); else//from ww w . ja v a 2 s . c o m throw new SocketException("StackConfiguration not complete"); }
From source file:org.pouzinsociety.socket.udp.SocketServer.java
public SocketServer(TransportLayer udpTransport, StackConfiguration stackConfiguration) throws SocketException { this.udpTransport = udpTransport; this.stackConfiguration = stackConfiguration; if (stackConfiguration.Complete()) new Thread(this).start(); else/*w ww . j a v a 2 s . c o m*/ throw new SocketException("StackConfiguration not complete"); }
From source file:org.apache.mina.springrpc.DefaultMinaRequestExecutor.java
private ReturnAddressAwareRemoteInvocationResult handleDisconnected( ReturnAddressAwareRemoteInvocation invocation) { Exception e = new SocketException("Client disconnected"); return new ReturnAddressAwareRemoteInvocationResult(invocation.getReturnAddress(), e); }
From source file:ch.cyberduck.core.socket.HttpProxyAwareSocket.java
@Override public void connect(final SocketAddress endpoint, final int timeout) throws IOException { if (proxy.type() == Proxy.Type.HTTP) { super.connect(proxy.address(), timeout); final InetSocketAddress address = (InetSocketAddress) endpoint; final OutputStream out = this.getOutputStream(); IOUtils.write(String.format("CONNECT %s:%d HTTP/1.0\n\n", address.getHostName(), address.getPort()), out, Charset.defaultCharset()); final InputStream in = this.getInputStream(); final String response = new LineNumberReader(new InputStreamReader(in)).readLine(); if (null == response) { throw new SocketException(String.format("Empty response from HTTP proxy %s", ((InetSocketAddress) proxy.address()).getHostName())); }//from w w w . j av a 2 s . c o m if (response.contains("200")) { in.skip(in.available()); } else { throw new SocketException(String.format("Invalid response %s from HTTP proxy %s", response, ((InetSocketAddress) proxy.address()).getHostName())); } } else { super.connect(endpoint, timeout); } }
From source file:com.comcast.cats.telnet.TelnetConnection.java
/** * Connect to the telnet client./*from ww w .ja va2 s. c o m*/ * * @param isEnterRequired * : sometime an ENTER key maybe required to reach the prompt. * * @return true: if connected. * * @throws SocketException * @throws IOException */ public synchronized Boolean connect(Boolean isEnterRequired) throws SocketException, IOException { if (!isConnected) { try { telnetClient.connect(getHost(), getPort()); logger.info("connected to telnet host " + host + " port " + port + " defaultPromptString " + defaultPromptString); } catch (SocketException e) { logger.warn("Could not connect to telnetSession " + e.getMessage()); throw new SocketException(e.getMessage()); } is = telnetClient.getInputStream(); os = new PrintStream(telnetClient.getOutputStream()); if (isEnterRequired) { os.println(); } isConnected = true; lastActiveTime = new Date(); } return isConnected; }
From source file:jnode.net.NetworkInterface.java
/** * Returns an network interface by name// w ww. j a v a 2 s.com * * @param name * The name of the interface to return * * @exception SocketException * If an error occurs * @exception NullPointerException * If the specified name is null */ public static NetworkInterface getByName(String name) throws SocketException { final VMNetDevice dev = VMNetUtils.getAPI().getByName(name); if (dev != null) { return new NetworkInterface(dev); } else { throw new SocketException("No network interface with this name exists"); } }
From source file:org.glite.security.trustmanager.tomcat.TMSSLServerSocketFactory.java
public Socket acceptSocket(ServerSocket sSocket) throws IOException { LOGGER.debug("TMSSLServerSocketFactory.acceptSocket:"); SSLSocket asock = null;/*from w w w . j av a 2 s . co m*/ try { asock = (SSLSocket) sSocket.accept(); configureClientAuth(asock); } catch (SSLException e) { throw new SocketException("SSL handshake error" + e.toString()); } return asock; }