本文整理汇总了Java中java.net.SocketException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java SocketException.getMessage方法的具体用法?Java SocketException.getMessage怎么用?Java SocketException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.SocketException
的用法示例。
在下文中一共展示了SocketException.getMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import java.net.SocketException; //导入方法依赖的package包/类
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);
}
}
示例2: getAllHostAddress
import java.net.SocketException; //导入方法依赖的package包/类
public static Collection<InetAddress> getAllHostAddress() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
Collection<InetAddress> addresses = new ArrayList<InetAddress>();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
addresses.add(inetAddress);
}
}
return addresses;
} catch (SocketException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例3: sendRtmpPacket
import java.net.SocketException; //导入方法依赖的package包/类
private void sendRtmpPacket(RtmpPacket rtmpPacket) {
try {
ChunkStreamInfo chunkStreamInfo =
rtmpSessionInfo.getChunkStreamInfo(rtmpPacket.getHeader().getChunkStreamId());
chunkStreamInfo.setPrevHeaderTx(rtmpPacket.getHeader());
if (!(rtmpPacket instanceof Video || rtmpPacket instanceof Audio)) {
rtmpPacket.getHeader()
.setAbsoluteTimestamp((int) chunkStreamInfo.markAbsoluteTimestampTx());
}
rtmpPacket.writeTo(outputStream, rtmpSessionInfo.getTxChunkSize(), chunkStreamInfo);
Log.d(TAG,
"wrote packet: " + rtmpPacket + ", size: " + rtmpPacket.getHeader().getPacketLength());
if (rtmpPacket instanceof Command) {
rtmpSessionInfo.addInvokedCommand(((Command) rtmpPacket).getTransactionId(),
((Command) rtmpPacket).getCommandName());
}
outputStream.flush();
} catch (SocketException se) {
// Since there are still remaining AV frame in the cache, we set a flag to guarantee the
// socket exception only issue one time.
if (!socketExceptionCause.contentEquals(se.getMessage())) {
socketExceptionCause = se.getMessage();
connectCheckerRtmp.onConnectionFailedRtmp("Error send packet: " + se.getMessage());
Log.e(TAG, "Caught SocketException during write loop, shutting down: " + se.getMessage());
}
} catch (IOException ioe) {
Log.e(TAG, "Caught IOException during write loop, shutting down: " + ioe.getMessage());
}
}
示例4: treatAsBindException
import java.net.SocketException; //导入方法依赖的package包/类
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"));
}