本文整理汇总了Java中java.net.SocketException.toString方法的典型用法代码示例。如果您正苦于以下问题:Java SocketException.toString方法的具体用法?Java SocketException.toString怎么用?Java SocketException.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.SocketException
的用法示例。
在下文中一共展示了SocketException.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIpAddress
import java.net.SocketException; //导入方法依赖的package包/类
private String getIpAddress() {
String ip = "";
try {
Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface.getNetworkInterfaces();
while (enumNetworkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = enumNetworkInterfaces.nextElement();
Enumeration<InetAddress> enumInetAddress = networkInterface.getInetAddresses();
while (enumInetAddress.hasMoreElements()) {
InetAddress inetAddress = enumInetAddress.nextElement();
if (inetAddress.isSiteLocalAddress()) {
ip += inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
ip += "Something Wrong! " + e.toString() + "\n";
}
return ip;
}
示例2: GetIpAddress
import java.net.SocketException; //导入方法依赖的package包/类
public String GetIpAddress() {
String ip = "";
try {
Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface.getNetworkInterfaces();
while (enumNetworkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = enumNetworkInterfaces.nextElement();
Enumeration<InetAddress> enumInetAddress = networkInterface.getInetAddresses();
while (enumInetAddress.hasMoreElements()) {
InetAddress inetAddress = enumInetAddress.nextElement();
if (inetAddress.isSiteLocalAddress()) {
ip += "SiteLocalAddress: " + inetAddress.getHostAddress() + "\n";
}
}
}
} catch (SocketException e) {
_logger.Error(e.toString());
ip += "Something Wrong! " + e.toString() + "\n";
}
return ip;
}
示例3: doBind
import java.net.SocketException; //导入方法依赖的package包/类
/**
* Creates the datagram socket.
*/
@Override
protected void doBind()
throws CommunicationException, InterruptedException {
try {
synchronized (this) {
socket = new DatagramSocket(port, address) ;
}
dbgTag = makeDebugTag();
} catch (SocketException e) {
if (e.getMessage().equals(InterruptSysCallMsg))
throw new InterruptedException(e.toString()) ;
else {
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
"doBind", "cannot bind on port " + port);
}
throw new CommunicationException(e) ;
}
}
}
示例4: getOurIpAddress
import java.net.SocketException; //导入方法依赖的package包/类
private String getOurIpAddress() {
String ip = "";
try {
Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface.getNetworkInterfaces();
while (enumNetworkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = enumNetworkInterfaces.nextElement();
Enumeration<InetAddress> enumInetAddress = networkInterface.getInetAddresses();
while (enumInetAddress.hasMoreElements()) {
InetAddress inetAddress = enumInetAddress.nextElement();
if (inetAddress.isSiteLocalAddress()) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ip += "Something Wrong! " + e.toString() + "\n";
}
return ip;
}