List of usage examples for java.net SocketException printStackTrace
public void printStackTrace()
From source file:com.cisco.cta.taxii.adapter.TcpServer.java
@Override public void run() { while (!closed) { try (Socket socket = serverSocket.accept(); InputStream in = socket.getInputStream()) { message = StreamUtils.copyToString(in, CHARSET); connectionCount++;/*from ww w .ja v a 2 s. c o m*/ } catch (SocketException e) { // closing server - do nothing } catch (Exception e) { errorCount++; e.printStackTrace(); } } }
From source file:com.willwinder.universalgcodesender.connection.TCPConnection.java
/** * Thread to accept data from remote host, and pass it to responseHandler *//*from ww w .j a v a 2 s.c o m*/ public void run() { String resp; while (!Thread.interrupted() && !client.isClosed()) { try { if (inStream.ready() && (resp = bufIn.readLine()) != null) { responseMessageHandler.handleResponse(resp + "\n", comm); } } catch (SocketException e) { e.printStackTrace(); return; // terminate thread if disconnected //TODO: at some point, reconnecting should be considered } catch (IOException e) { e.printStackTrace(); return; // terminate thread if disconnected //TODO: at some point, reconnecting should be considered } } }
From source file:com.cscao.apps.ntplib.NTPClient.java
private TimeInfo requestTime(String server, int timeout) { TimeInfo responseInfo = null;/* w ww . j ava 2 s .co m*/ NTPUDPClient client = new NTPUDPClient(); client.setDefaultTimeout(timeout); try { client.open(); try { InetAddress hostAddr = InetAddress.getByName(server); // System.out.println("> " + hostAddr.getHostName() + "/" // + hostAddr.getHostAddress()); details += "NTP server: " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress(); responseInfo = client.getTime(hostAddr); } catch (IOException ioe) { ioe.printStackTrace(); } } catch (SocketException e) { e.printStackTrace(); } client.close(); return responseInfo; }
From source file:org.dronix.android.unisannio.fragment.TabOne.java
public List<News> getNews() { List<News> newsList = new ArrayList<News>(); try {/*w w w . java2 s . c o m*/ Document doc = Jsoup.connect(URL).timeout(10000).get(); Elements newsItems = doc.select("div.meta > table > tbody > tr"); for (int i = 2; i < newsItems.size(); i++) { String date = null; Element dateElement = newsItems.get(i).select("p").first(); if (dateElement != null) { date = dateElement.text(); } String body = null; Element bodyElement = newsItems.get(i).select("a").first(); if (bodyElement != null) { body = bodyElement.text(); } if (date != null && body != null) newsList.add(new News(date, body)); } } catch (SocketException e) { return null; } catch (IOException e) { e.printStackTrace(); } /* * for (News n : newsList) { Log.i("NEWS", n.getDate() + " " + * n.getBody()); } */ return newsList; }
From source file:com.commonsware.android.webserver.secure.WebServerService.java
private void raiseReadyEvent() { ServerStartedEvent event = new ServerStartedEvent(); try {/* w w w . j ava 2 s . c o m*/ for (Enumeration<NetworkInterface> enInterfaces = NetworkInterface.getNetworkInterfaces(); enInterfaces .hasMoreElements();) { NetworkInterface ni = enInterfaces.nextElement(); for (Enumeration<InetAddress> enAddresses = ni.getInetAddresses(); enAddresses.hasMoreElements();) { InetAddress addr = enAddresses.nextElement(); if (addr instanceof Inet4Address) { event.addUrl("http://" + addr.getHostAddress() + ":4999" + rootPath + "/"); } } } } catch (SocketException ex) { ex.printStackTrace(); } EventBus.getDefault().removeAllStickyEvents(); EventBus.getDefault().postSticky(event); }
From source file:org.apache.hadoop.metrics.ganglia.GangliaContext.java
@InterfaceAudience.Private public void init(String contextName, ContextFactory factory) { super.init(contextName, factory); parseAndSetPeriod(PERIOD_PROPERTY);//from www . j a va 2 s . co m metricsServers = Util.parse(getAttribute(SERVERS_PROPERTY), DEFAULT_PORT); unitsTable = getAttributeTable(UNITS_PROPERTY); slopeTable = getAttributeTable(SLOPE_PROPERTY); tmaxTable = getAttributeTable(TMAX_PROPERTY); dmaxTable = getAttributeTable(DMAX_PROPERTY); try { datagramSocket = new DatagramSocket(); } catch (SocketException se) { se.printStackTrace(); } }
From source file:ca.viaware.dlna.ssdp.SSDPService.java
public void reply(String st, String usn, String uid, SocketAddress source) { String http = "HTTP/1.1 200 OK\r\n"; http += "CACHE-CONTROL: max-age=1800\r\n"; http += "EXT: \r\n"; http += "ST: " + st + "\r\n"; http += "USN: " + usn + "\r\n"; http += "SERVER: " + Globals.SERVER + "\r\n"; http += "LOCATION: http://" + httpConfig.getString("host") + ":" + httpConfig.getInt("port") + "/" + uid + "/\r\n"; http += "DATE: " + DateUtils.getDate() + "\r\n"; http += "\r\n"; try {/*from w ww.ja va 2 s . com*/ byte[] bytes = http.getBytes("UTF-8"); DatagramPacket p = new DatagramPacket(bytes, 0, bytes.length, source); outSock.send(p); Log.info("SSDP: M-SEARCH Reply sent to '" + source + "' successfully : ST: " + st + " : USN: " + usn); } catch (SocketException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.openhab.binding.smartbus.internal.SmartBusBinding.java
public void activate() { try {/*from www .ja v a 2s . c om*/ transportUdp = new TransportIP(this); } catch (SocketException e) { // TODO Auto-generated catch block e.printStackTrace(); } transportUdp.start(); logger.debug("transportUDP thread started!"); }
From source file:org.trosnoth.serveradmin.helpers.AutomatedTelnetClient.java
public void write(String value) { try {//from w w w . ja v a 2 s . c o m out.print(value + "\r\n"); out.flush(); telnet.getOutputStream().flush(); } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.commonsware.android.webserver.template.WebServerService.java
private void raiseReadyEvent() { ServerStartedEvent event = new ServerStartedEvent(); try {/*from w w w .ja v a 2 s . c o m*/ for (Enumeration<NetworkInterface> enInterfaces = NetworkInterface.getNetworkInterfaces(); enInterfaces .hasMoreElements();) { NetworkInterface ni = enInterfaces.nextElement(); for (Enumeration<InetAddress> enAddresses = ni.getInetAddresses(); enAddresses.hasMoreElements();) { InetAddress addr = enAddresses.nextElement(); if (addr instanceof Inet4Address) { event.addUrl("http://" + addr.getHostAddress() + ":4999"); } } } } catch (SocketException ex) { ex.printStackTrace(); } EventBus.getDefault().removeAllStickyEvents(); EventBus.getDefault().postSticky(event); }