java.net.SocketException.toString()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中java.net.SocketException.toString()方法的一些代码示例,展示了SocketException.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketException.toString()方法的具体详情如下:
包路径:java.net.SocketException
类名称:SocketException
方法名:toString

SocketException.toString介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

protected void _send(Message msg, Address dest) {
  try {
    send(msg, dest);
  }
  catch(InterruptedIOException iex) {
  }
  catch(InterruptedException interruptedEx) {
    Thread.currentThread().interrupt(); // let someone else handle the interrupt
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: ac-pm/Inspeckage

public void loadInterfaces(){
  StringBuilder sb = new StringBuilder();
  sb.append("All interfaces,");
  try {
    for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
      NetworkInterface netInterface = en.nextElement();
      for (Enumeration<InetAddress> enumIpAddr = netInterface.getInetAddresses(); enumIpAddr.hasMoreElements();) {
        InetAddress inetAddress = enumIpAddr.nextElement();
        String address = inetAddress.getHostAddress();
        boolean isIPv4 = address.indexOf(':') < 0;
        if (isIPv4) {
          sb.append(address+",");
        }
      }
    }
  } catch (SocketException ex) {
    Log.e("Inspeckage_Error", ex.toString());
  }
  SharedPreferences.Editor edit = mPrefs.edit();
  edit.putString(Config.SP_SERVER_INTERFACES, sb.toString().substring(0,sb.length()-1));
  edit.apply();
}
@Override

代码示例来源:origin: confluentinc/kafka-streams-examples

} catch (final java.net.SocketException exception) {
 log.error("Unavailable: " + hostInfo.host() + ":" + hostInfo.port());
 throw new Exception(exception.toString());

代码示例来源:origin: confluentinc/kafka-streams-examples

/**
 * Start an embedded Jetty Server
 * @throws Exception
 */
void start() throws Exception {
 ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
 context.setContextPath("/");
 jettyServer = new Server();
 jettyServer.setHandler(context);
 ResourceConfig rc = new ResourceConfig();
 rc.register(this);
 rc.register(JacksonFeature.class);
 ServletContainer sc = new ServletContainer(rc);
 ServletHolder holder = new ServletHolder(sc);
 context.addServlet(holder, "/*");

 final ServerConnector connector = new ServerConnector(jettyServer);
 connector.setHost(hostInfo.host());
 connector.setPort(hostInfo.port());
 jettyServer.addConnector(connector);

 context.start();

 try {
  jettyServer.start();
 } catch (final java.net.SocketException exception) {
  log.error("Unavailable: " + hostInfo.host() + ":" + hostInfo.port());
  throw new Exception(exception.toString());
 }
}

代码示例来源:origin: jamesagnew/hapi-fhir

myServer.start();
} catch (SocketException e) {
  throw new CommandFailureException("Server failed to start on port " + myPort + " because of the following error \"" + e.toString() + "\". Note that you can use the '-p' option to specify an alternate port."); 
} catch (Exception e) {
  ourLog.error("Server failed to start", e);

代码示例来源:origin: KostyaSha/yet-another-docker-plugin

@Override
 public String toString() {
  if (socketFile == null) {
   return super.toString();
  } else {
   return super.toString() + " (socket: " + socketFile + ")";
  }
 }
}

代码示例来源:origin: baratine/baratine

@Override
public long getSoTimeout()
{
 try {
  return _s.getSoTimeout();
 } catch (SocketException e) {
  log.log(Level.FINEST, e.toString(), e);
  
  return -1;
 }
}

代码示例来源:origin: blurpy/kouchat-android

/**
 * Gets all the available network interfaces. Returns <code>null</code>
 * if the operation fails, or no interfaces are available.
 *
 * @return All network interfaces, or <code>null</code>.
 */
@Nullable
public Enumeration<NetworkInterface> getNetworkInterfaces() {
  Enumeration<NetworkInterface> networkInterfaces = null;
  try {
    networkInterfaces = NetworkInterface.getNetworkInterfaces();
  }
  catch (final SocketException e) {
    LOG.log(Level.WARNING, e.toString());
  }
  return networkInterfaces;
}

代码示例来源:origin: drulabs/LocalDash

public static String getMyIpAddress() {
  try {
    for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
      NetworkInterface intf = en.nextElement();
      for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
        InetAddress inetAddress = enumIpAddr.nextElement();
        if (!inetAddress.isLoopbackAddress()) {
          return inetAddress.getHostAddress();
        }
      }
    }
  } catch (SocketException ex) {
    Log.e("Utility", ex.toString());
  }
  return null;
}

代码示例来源:origin: Hotel-Reservation-Service/FillTheForm

private String getLocalIpAddress() {
    try {
      for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
        NetworkInterface networkInterface = en.nextElement();
        for (Enumeration<InetAddress> enumIpAddress = networkInterface.getInetAddresses(); enumIpAddress.hasMoreElements(); ) {
          InetAddress inetAddress = enumIpAddress.nextElement();
          if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
            return inetAddress.getHostAddress();
          }
        }
      }
    } catch (SocketException ex) {
      LogUtil.d(TAG, ex.toString());
    }
    return deviceIpAddressFailure;
  }
}

代码示例来源:origin: com.caucho/resin

public int read(byte []buf, int offset, int length) throws IOException
{
 StreamImpl stream = _stream;
 
 if (stream != null) {
  int len;
  
  try {
   len = stream.read(buf, offset, length);
  } catch (SocketException e) {
   log.log(Level.FINER, e.toString(), e);
   len = -1;
  }
  
  if (len < 0)
   close();
 
  return len;
 }
 else
  return -1;
}

代码示例来源:origin: apache/activemq-artemis

protected void _send(Message msg, Address dest) {
  try {
    send(msg, dest);
  }
  catch(InterruptedIOException iex) {
  }
  catch(InterruptedException interruptedEx) {
    Thread.currentThread().interrupt(); // let someone else handle the interrupt
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void _send(Message msg, Address dest) {
  try {
    send(msg, dest);
  }
  catch(InterruptedIOException iex) {
  }
  catch(InterruptedException interruptedEx) {
    Thread.currentThread().interrupt(); // let someone else handle the interrupt
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         local_addr, (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(final Message msg) {
  Address dest=msg.getDest();
  try {
    Util.writeMessage(msg, output, dest == null);
    transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
    if(transport.statsEnabled())
      transport.incrSingleMsgsInsteadOfBatches();
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(final Message msg) {
  Address dest=msg.getDest();
  try {
    Util.writeMessage(msg, output, dest == null);
    transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
    if(transport.statsEnabled())
      transport.incrSingleMsgsInsteadOfBatches();
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(Message msg, ByteArrayDataOutputStream output) {
    Address dest = msg.getDest();
    try {
      Util.writeMessage(msg, output, dest == null);
      transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
      if(transport.statsEnabled())
        transport.incrSingleMsgsInsteadOfBatches();
    }
    catch(SocketException sock_ex) {
      log.trace(Util.getMessage("SendFailure"),
           transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
    }
    catch(Throwable e) {
      log.error(Util.getMessage("SendFailure"),
           transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
    }
  }
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

protected void sendSingleMessage(final Message msg) {
  Address dest=msg.getDest();
  try {
    Util.writeMessage(msg, output, dest == null);
    transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
    if(transport.statsEnabled())
      transport.incrSingleMsgsInsteadOfBatches();
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(Message msg, ByteArrayDataOutputStream output) {
    Address dest = msg.getDest();
    try {
      Util.writeMessage(msg, output, dest == null);
      transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
      if(transport.statsEnabled())
        transport.incrSingleMsgsInsteadOfBatches();
    }
    catch(SocketException sock_ex) {
      log.trace(Util.getMessage("SendFailure"),
           transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
    }
    catch(Throwable e) {
      log.error(Util.getMessage("SendFailure"),
           transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
    }
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(final Message msg, final ByteArrayDataOutputStream output) {
  Address dest=msg.getDest();
  try {
    output.position(0);
    Util.writeMessage(msg, output, dest == null);
    transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
    if(transport.statsEnabled())
      transport.incrSingleMsgsInsteadOfBatches();
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void sendSingleMessage(final Message msg, final ByteArrayDataOutputStream output) {
  Address dest=msg.getDest();
  try {
    output.position(0);
    Util.writeMessage(msg, output, dest == null);
    transport.doSend(transport.getClusterName(msg), output.buffer(), 0, output.position(), dest);
    if(transport.statsEnabled())
      transport.incrSingleMsgsInsteadOfBatches();
  }
  catch(SocketException sock_ex) {
    log.trace(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), sock_ex.toString(), msg.printHeaders());
  }
  catch(Throwable e) {
    log.error(Util.getMessage("SendFailure"),
         transport.localAddress(), (dest == null? "cluster" : dest), msg.size(), e.toString(), msg.printHeaders());
  }
}

相关文章