List of usage examples for java.net SocketException printStackTrace
public void printStackTrace()
From source file:think_2.ThinkGearSocket.java
@Override public void run() { if (running && neuroSocket.isConnected()) { String userInput;//from w w w .j av a 2 s. c om try { while ((userInput = stdIn.readLine()) != null) { String[] packets = userInput.split("/\r/"); for (int s = 0; s < packets.length; s++) { if (((String) packets[s]).indexOf("{") > -1) { JSONObject obj = new JSONObject((String) packets[s]); parsePacket(obj); } //String name = obj.get("name").toString(); } } } catch (SocketException e) { //System.out.println("For some reason stdIn throws error even if closed"); //maybe it takes a cycle to close properly? //e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block //e.printStackTrace(); } //TODO: Ajusta para funcionar na implementao atual //parent.delay(50); try { Thread.sleep(50); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { running = false; } }
From source file:autobahn.WebSocketWriter.java
/** * Process message received from foreground thread. This is called from * the message looper set up for the background thread running this writer. * * @param msg Message from thread message queue. *///from ww w. jav a 2 s.c om @Override public void handleMessage(Message msg) { try { // clear send buffer mBuffer.clear(); // process message from master processMessage(msg.obj); // send out buffered data mBuffer.flip(); while (mBuffer.remaining() > 0) { // this can block on socket write @SuppressWarnings("unused") int written = mSocket.write(mBuffer.getBuffer()); } } catch (SocketException e) { if (DEBUG) Log.d(TAG, "run() : SocketException (" + e.toString() + ")"); // wrap the exception and notify master notify(new WebSocketMessage.ConnectionLost()); } catch (Exception e) { if (DEBUG) e.printStackTrace(); // wrap the exception and notify master notify(new WebSocketMessage.Error(e)); } }
From source file:edu.ku.brc.specify.config.init.TaxonLoadSetupPanel.java
/** * @return//www .j a v a2s.c o m */ private String getTaxonDOMStr() { URL url; try { String downloadHTTP = UIRegistry.getResourceString(DWNLD_TAX_URL); if (StringUtils.isNotEmpty(downloadHTTP)) { url = new URL(downloadHTTP + "/taxonfiles.xml"); URLConnection conn = url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; StringBuilder sb = new StringBuilder(); while ((line = in.readLine()) != null) { sb.append(line); } in.close(); return sb.toString(); } else { UIRegistry.showLocalizedError(BAD_TAXON_URL); } } catch (java.net.SocketException e) { UIRegistry.showLocalizedError(BAD_TAXON_DEF_NC); } catch (java.net.UnknownHostException e) { UIRegistry.showLocalizedError(BAD_TAXON_DEF_NC); } catch (Exception e) { e.printStackTrace(); UIRegistry.showLocalizedError(BAD_TAXON_DEF_DL); } return null; }
From source file:org.monome.pages.Configuration.java
public void initAbletonOSCOut() { try {//from w w w .java 2 s. c o m this.abletonOSCPortOut = new OSCPortOut(InetAddress.getByName(this.abletonHostname), this.abletonOSCOutPortNumber); } catch (SocketException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); } }
From source file:com.cubic9.android.droidglove.Main.java
/** * get IP Address of phone/*from w w w .j a v a 2 s. c o m*/ * @return IP address String or error message */ private String getIPAddress() { Enumeration<NetworkInterface> interfaces = null; try { interfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { new AlertDialog.Builder(Main.this).setIcon(android.R.drawable.ic_dialog_alert) .setTitle(getString(R.string.dialog_error_title)) .setMessage(getString(R.string.dialog_error_get_ip)) .setPositiveButton(R.string.dialog_error_ok, null).create().show(); e.printStackTrace(); } while (interfaces.hasMoreElements()) { NetworkInterface network = interfaces.nextElement(); Enumeration<InetAddress> addresses = network.getInetAddresses(); while (addresses.hasMoreElements()) { String address = addresses.nextElement().getHostAddress(); // If found not 127.0.0.1 and not 0.0.0.0, return it if (!"127.0.0.1".equals(address) && !"0.0.0.0".equals(address) && InetAddressUtils.isIPv4Address(address)) { return address; } } } return "An error occured while getting IP address."; }
From source file:org.monome.pages.Configuration.java
public void initAbletonOSCIn() { try {// w w w . j a v a 2 s . c o m if (this.abletonOSCPortIn != null) { this.abletonOSCPortIn.stopListening(); this.abletonOSCPortIn.close(); } this.abletonOSCPortIn = new OSCPortIn(this.abletonOSCInPortNumber); this.abletonOSCPortIn.addListener("/live/track/info", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/clip/info", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/state", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/mute", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/arm", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/solo", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/scene", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/tempo", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/overdub", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/refresh", this.abletonOSCListener); this.abletonOSCPortIn.addListener("/live/reset", this.abletonOSCListener); this.abletonOSCPortIn.startListening(); } catch (SocketException e) { e.printStackTrace(); } }
From source file:de.tavendo.autobahn.WebSocketWriter.java
/** * Process message received from foreground thread. This is called from * the message looper set up for the background thread running this writer. * * @param msg Message from thread message queue. */// w w w . j av a2 s . c o m @Override public void handleMessage(Message msg) { try { // clear send buffer mBuffer.clear(); // process message from master processMessage(msg.obj); // send out buffered data if (null != mSSLEngine) { write(mSocket, mSSLEngine, mBuffer.getBuffer()); } else { mBuffer.flip(); while (mBuffer.remaining() > 0) { // this can block on socket write @SuppressWarnings("unused") int written = mSocket.write(mBuffer.getBuffer()); } } } catch (SocketException e) { if (DEBUG) Log.d(TAG, "run() : SocketException (" + e.toString() + ")"); // wrap the exception and notify master notify(new WebSocketMessage.ConnectionLost()); } catch (Exception e) { if (DEBUG) e.printStackTrace(); // wrap the exception and notify master notify(new WebSocketMessage.Error(e)); } }
From source file:de.mangelow.throughput.NotificationService.java
private String getIPAddress() { try {/*from www . ja v a 2 s .c om*/ String ipv4; List<NetworkInterface> nilist = Collections.list(NetworkInterface.getNetworkInterfaces()); if (nilist.size() > 0) { for (NetworkInterface ni : nilist) { List<InetAddress> ialist = Collections.list(ni.getInetAddresses()); if (ialist.size() > 0) { for (InetAddress address : ialist) { if (!address.isLoopbackAddress() && InetAddressUtils.isIPv4Address(ipv4 = address.getHostAddress())) { return ipv4; } } } } } } catch (SocketException ex) { if (D) ex.printStackTrace(); } return ""; }
From source file:org.deviceconnect.android.deviceplugin.chromecast.profile.ChromeCastMediaPlayerProfile.java
/** * IP??/*from w ww . j a v a2s. c o m*/ * * @param ?? * @return IP */ private String getIpAddress() { try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = (NetworkInterface) networkInterfaces.nextElement(); Enumeration<InetAddress> ipAddrs = networkInterface.getInetAddresses(); while (ipAddrs.hasMoreElements()) { InetAddress ip = (InetAddress) ipAddrs.nextElement(); String ipStr = ip.getHostAddress(); if (!ip.isLoopbackAddress() && InetAddressUtils.isIPv4Address(ipStr)) { return ipStr; } } } } catch (SocketException e) { if (BuildConfig.DEBUG) { e.printStackTrace(); } } return null; }
From source file:org.speechforge.zanzibar.sip.SipServer.java
public void startup() { _logger.info("Starting sip Server!"); try {/*from w ww .ja v a 2s . c o m*/ if (zanzibarHostName == null) zanzibarHostName = CairoUtil.getLocalHost().getHostAddress(); if (cairoSipHostName == null) cairoSipHostName = CairoUtil.getLocalHost().getHostAddress(); } catch (SocketException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (UnknownHostException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } try { _sipAgent = new SipAgent(this, mySipAddress, stackName, zanzibarHostName, null, port, transport); } catch (SipException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } waitingList = new HashMap<String, SessionPair>(); _logger.info("Returned from call to Start sip Server!"); if (mode.equals("cloud")) { try { _replicatorPool = RTPStreamReplicatorFactory.createObjectPool(baseReceiverRtpPort, maxConnects, InetAddress.getByName(zanzibarHostName)); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } _portPairPool = new PortPairPool(baseXmitRtpPort, maxConnects); } }