Example usage for java.net SocketException printStackTrace

List of usage examples for java.net SocketException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.oucho.whois.LookupWhoisTask.java

protected String doInBackground(String... urls) {
    String url = urls[0];/*  www  .ja v  a2 s.  co  m*/

    String[] parts = url.split("\\:");
    String adresse = parts[0];
    String host = parts[1];

    if ("whois.internic.net".equals(host))
        adresse = "=" + adresse;

    StringBuilder result = new StringBuilder("");

    WhoisClient whois = new WhoisClient();

    try {
        whois.connect(host);
        String whoisData1 = whois.query(adresse);
        result.append(whoisData1);
        whois.disconnect();
    } catch (SocketException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return result.toString();
}

From source file:net.sourceforge.atunes.kernel.modules.player.vlcplayer.VlcTelnetClient.java

protected VlcTelnetClient(String newServer, int newPort) throws VlcTelnetClientException {

    // wait a title time for vlc process to be created 
    try {/*from  w w  w . ja  v  a2 s . c o  m*/
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        //we do nothing special
        //e.printStackTrace();
    }

    // Connect to the specified server
    logger.debug(LogCategories.NETWORK,
            "VlcTelnetClient : Connecting to port : " + newPort + " on server : " + newServer);

    try {
        telnet.connect(newServer, newPort);
    } catch (SocketException se) {
        se.printStackTrace();
        throw new VlcTelnetClientException(
                "Error while connecting to : " + newServer + " on : " + newPort + " : " + se.toString(), se);
    } catch (IOException ioe) {
        ioe.printStackTrace();
        throw new VlcTelnetClientException(
                "Error while connecting to : " + newServer + " on : " + newPort + " : " + ioe.toString(), ioe);
    }

    // Get input and output stream references
    try {
        in = telnet.getInputStream();
        out = new PrintStream(telnet.getOutputStream());
        //throw new Exception("Can't write or read form telnet client");
    } catch (Exception ex) {
        throw new VlcTelnetClientException("Can't write or read form telnet client", ex);
    }

}

From source file:network.UDPServer.java

public UDPServer(int port, ServerHandler serverHandle) {
    this.port = port;
    this.serverHandler = serverHandle;
    try {/* w  ww  . ja v a2  s .  c  o  m*/
        this.socket = new DatagramSocket(this.port);
        //this.executorService = Executors.newFixedThreadPool(50);
        this.executorService = Executors.newCachedThreadPool();
    } catch (SocketException e) {
        e.printStackTrace();
    }
}

From source file:org.cloudata.core.common.metrics.GangliaContext31.java

public synchronized void startMonitoring() {
    try {//from ww  w.ja  va2 s. c o m
        hostName = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException e) {
    }

    try {
        datagramSocket = new DatagramSocket();
    } catch (SocketException se) {
        se.printStackTrace();
    }
    super.startMonitoring();

}

From source file:de.tud.kitchen.android.NTPTimeReceiver.java

@Override
protected Void doInBackground(InetAddress... params) {
    NTPUDPClient client = new NTPUDPClient();
    client.setDefaultTimeout(10000);/*from  w  w  w .jav a 2 s .  c o  m*/
    try {
        client.open();
    } catch (final SocketException se) {
        se.printStackTrace();
        return null;
    }
    while (!this.isCancelled()) {
        try {
            TimeInfo info = client.getTime(params[0]);
            info.computeDetails();
            Long offsetValue = info.getOffset();
            int receiverTimeDelta = (offsetValue == null) ? 0 : offsetValue.intValue();
            publishProgress(receiverTimeDelta);
        } catch (final IOException ioe) {
            ioe.printStackTrace();
            continue;
        }

        try {
            Thread.sleep(1000 * 60);
        } catch (InterruptedException e) {
            continue;
        }
    }
    client.close();
    return null;
}

From source file:com.ecrimebureau.Web.Entity.WhoisS.java

private String queryWithWhoisServer(String domainName, String whoisServer) {

    String result = "";
    WhoisClient whois = new WhoisClient();
    try {//from  ww w . j  av a2 s  .  c  om

        whois.connect(whoisServer);
        result = whois.query(domainName);
        whois.disconnect();

    } catch (SocketException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return result;

}

From source file:com.ecrimebureau.Web.Entity.WhoisS.java

public String getWhois(String domainName) {

    StringBuilder result = new StringBuilder("");

    WhoisClient whois = new WhoisClient();
    try {/*from   w  w  w.j a v  a 2  s.  co  m*/

        whois.connect(WhoisClient.DEFAULT_HOST);

        // whois =google.com
        String whoisData1 = whois.query("=" + domainName);

        // append first result
        result.append(whoisData1);
        whois.disconnect();

        // get the google.com whois server - whois.markmonitor.com
        String whoisServerUrl = getWhoisServer(whoisData1);
        if (!whoisServerUrl.equals("")) {

            // whois -h whois.markmonitor.com google.com
            String whoisData2 = queryWithWhoisServer(domainName, whoisServerUrl);

            // append 2nd result
            result.append(whoisData2);
        }

    } catch (SocketException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return result.toString();

}

From source file:org.umit.icm.mobile.connectivity.ServiceFTP.java

/**
 * Returns an FTP Response String./*  w w w  .  j  a  v  a2  s. c o m*/
 * 
 *                                                                                                 
              
@return      String
 *
         
@see FTPClient
 */
@Override
public String connect() {

    FTPClient ftpClient = new FTPClient();
    try {
        ftpClient.connect(getServiceURL());
        ftpClient.login("test", "test");
        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
        ftpClient.enterLocalPassiveMode();
        String reply = ftpClient.getReplyString();
        ftpClient.logout();
        ftpClient.disconnect();
        if (reply != null)
            return "normal";
        return "blocked";
    } catch (SocketException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:ch.luethi.skylinestracker.PositionService.java

private SkyLinesTrackingWriter getOrCreateSkyLinesTrackingWriter() {
    if (skyLinesTrackingWriter == null) {
        try {/*from  w w  w  .j a v  a  2s .  c o m*/
            skyLinesTrackingWriter = new SkyLinesTrackingWriter(prefs.getTrackingKey(), ipAddress);
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
    return skyLinesTrackingWriter;
}

From source file:com.comcast.cats.TelnetConnectionTest.java

private void connectTelnet(Boolean isEnterRequired, String password) {
    try {/*w  ww.  j a v  a2 s . com*/
        if (enableMock) {
            telnetClient.connect(host, port);
            EasyMock.expectLastCall().atLeastOnce();
            telnetClient.setSoTimeout(TelnetConnection.DEFAULT_READ_TIMEOUT);

            EasyMock.expectLastCall().anyTimes();
            EasyMock.expect(telnetClient.getInputStream()).andReturn(is).anyTimes();
            EasyMock.expect(telnetClient.getOutputStream()).andReturn(os).anyTimes();
            EasyMock.expect(telnetClient.isConnected()).andReturn(true).anyTimes();
            telnetClient.disconnect();
            EasyMock.expectLastCall().anyTimes();

            EasyMock.replay(telnetClient);

            is.close();
            EasyMock.expectLastCall().atLeastOnce();
            EasyMock.expect(is.read()).andReturn(62).anyTimes();
            EasyMock.replay(is);

        }

        if (password == null) {
            telnetConnecton.connect(isEnterRequired);
        } else {
            telnetConnecton.connectWithPassword(password, ">", isEnterRequired);
        }
    } catch (SocketException e) {
        e.printStackTrace();
        fail();

    } catch (IOException e) {
        e.printStackTrace();
        fail();

    }
}