当前位置: 首页>>代码示例>>Java>>正文


Java SocketException.toString方法代码示例

本文整理汇总了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;
}
 
开发者ID:yuvaraj119,项目名称:WifiChatSharing,代码行数:24,代码来源:MessageActivity.java

示例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;
}
 
开发者ID:GuepardoApps,项目名称:PasswordSafe-AndroidClient,代码行数:21,代码来源:NetworkController.java

示例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) ;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:SnmpAdaptorServer.java

示例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;
}
 
开发者ID:BloomBooks,项目名称:BloomReader,代码行数:27,代码来源:NewBookListenerService.java


注:本文中的java.net.SocketException.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。