本文整理了Java中java.net.SocketException.getMessage()
方法的一些代码示例,展示了SocketException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketException.getMessage()
方法的具体详情如下:
包路径:java.net.SocketException
类名称:SocketException
方法名:getMessage
暂无
代码示例来源:origin: apache/geode
public static boolean treatAsBindException(SocketException se) {
if (se instanceof BindException) {
return true;
}
final String msg = se.getMessage();
return (msg != null && msg.contains("Invalid argument: listen failed"));
}
代码示例来源:origin: apache/geode
public static boolean treatAsBindException(SocketException se) {
if (se instanceof BindException) {
return true;
}
final String msg = se.getMessage();
return (msg != null && msg.contains("Invalid argument: listen failed"));
}
代码示例来源:origin: square/okhttp
private void acceptConnections() throws Exception {
while (true) {
Socket socket;
try {
socket = serverSocket.accept();
} catch (SocketException e) {
logger.info(MockWebServer.this + " done accepting connections: " + e.getMessage());
return;
}
SocketPolicy socketPolicy = dispatcher.peek().getSocketPolicy();
if (socketPolicy == DISCONNECT_AT_START) {
dispatchBookkeepingRequest(0, socket);
socket.close();
} else {
openClientSockets.add(socket);
serveConnection(socket);
}
}
}
});
代码示例来源:origin: bwssytems/ha-bridge
private boolean initializeSocket(int port) {
log.info("Initializing UDP response Socket...");
udpResponsePort = port;
boolean portLoopControl = true;
int retryCount = 0;
while(portLoopControl) {
try {
responseSocket = new DatagramSocket(udpResponsePort);
portLoopControl = false;
} catch(SocketException e) {
if(retryCount == 0)
log.warn("UDP Response Port is in use, starting loop to find open port for 20 tries - configured port is: " + udpResponsePort);
if(retryCount >= 20) {
portLoopControl = false;
log.error("UDP Response Port issue, could not find open port - last port tried: " + udpResponsePort + " with message: " + e.getMessage());
return false;
}
}
if(portLoopControl) {
retryCount++;
udpResponsePort++;
}
}
log.info("UDP response Socket initialized to: " + udpResponsePort);
return true;
}
代码示例来源:origin: netty/netty
AnnotatedSocketException(SocketException exception, SocketAddress remoteAddress) {
super(exception.getMessage() + ": " + remoteAddress);
initCause(exception);
setStackTrace(exception.getStackTrace());
}
代码示例来源:origin: neo4j/neo4j
@Override
void dump( Logger logger )
{
try
{
Enumeration<NetworkInterface> networkInterfaces = getNetworkInterfaces();
while ( networkInterfaces.hasMoreElements() )
{
NetworkInterface iface = networkInterfaces.nextElement();
logger.log( String.format( "Interface %s:", iface.getDisplayName() ) );
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while ( addresses.hasMoreElements() )
{
InetAddress address = addresses.nextElement();
String hostAddress = address.getHostAddress();
logger.log( " address: %s", hostAddress );
}
}
}
catch ( SocketException e )
{
logger.log( "ERROR: failed to inspect network interfaces and addresses: " + e.getMessage() );
}
}
},
代码示例来源:origin: redisson/redisson
AnnotatedSocketException(SocketException exception, SocketAddress remoteAddress) {
super(exception.getMessage() + ": " + remoteAddress);
initCause(exception);
setStackTrace(exception.getStackTrace());
}
代码示例来源:origin: bwssytems/ha-bridge
ifs = NetworkInterface.getNetworkInterfaces();
} catch(SocketException e) {
log.error("checkIpAddress cannot get ip address of this host, Exiting with message: " + e.getMessage(), e);
return null;
代码示例来源:origin: apache/hbase
/**
* A convenience method to bind to a given address and report
* better exceptions if the address is not a valid host.
* @param socket the socket to bind
* @param address the address to bind to
* @param backlog the number of connections allowed in the queue
* @throws BindException if the address can't be bound
* @throws UnknownHostException if the address isn't a valid host name
* @throws IOException other random errors from bind
*/
public static void bind(ServerSocket socket, InetSocketAddress address,
int backlog) throws IOException {
try {
socket.bind(address, backlog);
} catch (BindException e) {
BindException bindException =
new BindException("Problem binding to " + address + " : " +
e.getMessage());
bindException.initCause(e);
throw bindException;
} catch (SocketException e) {
// If they try to bind to a different host's address, give a better
// error message.
if ("Unresolved address".equals(e.getMessage())) {
throw new UnknownHostException("Invalid hostname for server: " +
address.getHostName());
}
throw e;
}
}
代码示例来源:origin: wildfly/wildfly
AnnotatedSocketException(SocketException exception, SocketAddress remoteAddress) {
super(exception.getMessage() + ": " + remoteAddress);
initCause(exception);
setStackTrace(exception.getStackTrace());
}
代码示例来源:origin: apache/zeppelin
public ClusterManager() {
try {
zeplServerHost = RemoteInterpreterUtils.findAvailableHostAddress();
String clusterAddr = zconf.getClusterAddress();
if (!StringUtils.isEmpty(clusterAddr)) {
String cluster[] = clusterAddr.split(",");
for (int i = 0; i < cluster.length; i++) {
String[] parts = cluster[i].split(":");
String clusterHost = parts[0];
int clusterPort = Integer.valueOf(parts[1]);
if (zeplServerHost.equalsIgnoreCase(clusterHost)) {
raftServerPort = clusterPort;
}
Node node = Node.builder().withId(cluster[i])
.withAddress(Address.from(clusterHost, clusterPort)).build();
clusterNodes.add(node);
raftAddressMap.put(MemberId.from(cluster[i]), Address.from(clusterHost, clusterPort));
clusterMemberIds.add(MemberId.from(cluster[i]));
}
}
} catch (UnknownHostException e) {
LOGGER.error(e.getMessage());
} catch (SocketException e) {
LOGGER.error(e.getMessage());
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private void init() {
ServerSocketChannel socketChannel = processor.javaChannel();
ServerSocket javaSocket = socketChannel.socket();
try {
if (serverConfig.getReceiveBufferSize() != null) {
javaSocket.setReceiveBufferSize(serverConfig.getReceiveBufferSize());
}
if (serverConfig.getReuseAddress() != null) {
javaSocket.setReuseAddress(serverConfig.getReuseAddress());
}
} catch (SocketException e) {
throw new NioException("config channel error:" + e.getMessage(), e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private void init() {
ServerSocketChannel socketChannel = processor.javaChannel();
ServerSocket javaSocket = socketChannel.socket();
try {
if (serverConfig.getReceiveBufferSize() != null) {
javaSocket.setReceiveBufferSize(serverConfig.getReceiveBufferSize());
}
if (serverConfig.getReuseAddress() != null) {
javaSocket.setReuseAddress(serverConfig.getReuseAddress());
}
} catch (SocketException e) {
throw new NioException("config channel error:" + e.getMessage(), e);
}
}
代码示例来源:origin: netty/netty
if (!e.getMessage().toLowerCase(Locale.US).contains("socket closed")) {
throw e;
代码示例来源:origin: apache/incubator-gobblin
@Override
void handleClientSocket(Socket clientSocket) throws IOException {
LOG.info("Writing to client");
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
PrintWriter out = new PrintWriter(clientSocket.getOutputStream());
try {
out.println("Hello");
out.flush();
String line = in.readLine();
while (line != null && isServerRunning()) {
out.println(line + " " + line);
out.flush();
line = in.readLine();
}
}
catch (SocketException se) {
// don't bring down server when client disconnected abruptly
if (!se.getMessage().contains("Connection reset")) {
throw se;
}
}
finally {
clientSocket.close();
}
}
}
代码示例来源:origin: apache/zookeeper
LOG.warn("Interrupted", e);
} catch (SocketException e) {
if (!"Socket closed".equals(e.getMessage())) {
LOG.error("Unexpected exception", e);
代码示例来源:origin: redisson/redisson
if (!e.getMessage().toLowerCase(Locale.US).contains("socket closed")) {
throw e;
代码示例来源:origin: wildfly/wildfly
if (!e.getMessage().toLowerCase(Locale.US).contains("socket closed")) {
throw e;
代码示例来源:origin: apache/hbase
/**
* Checks whether we are effected by the JDK issue on windows, and if so
* ensures that we are running with preferIPv4Stack=true.
*/
@Test
public void testServerSocket() throws IOException {
byte[] addr = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
InetAddress inetAddr = InetAddress.getByAddress(addr);
try {
bindServerSocket(inetAddr);
bindNIOServerSocket(inetAddr);
//if on *nix or windows JDK7, both will pass
} catch(java.net.SocketException ex) {
//On Windows JDK6, we will get expected exception:
//java.net.SocketException: Address family not supported by protocol family
//or java.net.SocketException: Protocol family not supported
Assert.assertFalse(ex instanceof BindException);
Assert.assertTrue(ex.getMessage().toLowerCase(Locale.ROOT).contains("protocol family"));
LOG.info("Received expected exception:", ex);
//if this is the case, ensure that we are running on preferIPv4=true
ensurePreferIPv4();
}
}
代码示例来源:origin: apache/zookeeper
LOG.warn("Couldn't find loopback interface: " + se.getMessage());
内容来源于网络,如有侵权,请联系作者删除!