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


Java Socket.getLocalSocketAddress方法代码示例

本文整理汇总了Java中java.net.Socket.getLocalSocketAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Socket.getLocalSocketAddress方法的具体用法?Java Socket.getLocalSocketAddress怎么用?Java Socket.getLocalSocketAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.Socket的用法示例。


在下文中一共展示了Socket.getLocalSocketAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toString

import java.net.Socket; //导入方法依赖的package包/类
@Override
public String toString() {
    final Socket socket = this.socketHolder.get();
    if (socket != null) {
        final StringBuilder buffer = new StringBuilder();
        final SocketAddress remoteAddress = socket.getRemoteSocketAddress();
        final SocketAddress localAddress = socket.getLocalSocketAddress();
        if (remoteAddress != null && localAddress != null) {
            NetUtils.formatAddress(buffer, localAddress);
            buffer.append("<->");
            NetUtils.formatAddress(buffer, remoteAddress);
        }
        return buffer.toString();
    } else {
        return "[Not bound]";
    }
}
 
开发者ID:gusavila92,项目名称:java-android-websocket-client,代码行数:18,代码来源:BHttpConnectionBase.java

示例2: getAddress

import java.net.Socket; //导入方法依赖的package包/类
@Override
public InetSocketAddress
getAddress()
{
	SocketChannel channel = ep.getSocketChannel();

	if ( channel != null ){

		Socket socket = channel.socket();

		if ( socket != null ){

			return((InetSocketAddress)socket.getLocalSocketAddress());
		}
	}

	return( null );
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:19,代码来源:TransportStartpointTCP.java

示例3: getLocalAddress

import java.net.Socket; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public InetSocketAddress getLocalAddress() {
    if (channel == null) {
        return null;
    }

    Socket socket = getSocket();

    if (socket == null) {
        return null;
    }

    return (InetSocketAddress) socket.getLocalSocketAddress();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:NioSocketSession.java

示例4: updateSocketAddresses

import java.net.Socket; //导入方法依赖的package包/类
private void updateSocketAddresses() {
    Socket socket = ((SocketChannel) sockKey.channel()).socket();
    localSocketAddress = socket.getLocalSocketAddress();
    remoteSocketAddress = socket.getRemoteSocketAddress();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:6,代码来源:ClientCnxnSocketNIO.java


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