本文整理汇总了Java中jnr.unixsocket.UnixSocketAddress类的典型用法代码示例。如果您正苦于以下问题:Java UnixSocketAddress类的具体用法?Java UnixSocketAddress怎么用?Java UnixSocketAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnixSocketAddress类属于jnr.unixsocket包,在下文中一共展示了UnixSocketAddress类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public Socket createSocket() throws IOException {
logger.info(String.format("Connecting to Cloud SQL instance [%s].", instanceName));
// This env will be set by GAE OR set manually if using Cloud SQL Proxy
String runtime = System.getenv("GAE_RUNTIME");
if (runtime == null || runtime.isEmpty()) { // Use standard SSL (direct connection)
return SslSocketFactory.getInstance().create(instanceName);
}
logger.info("GAE Unix Sockets");
UnixSocketAddress socketAddress = new UnixSocketAddress(
new File(CloudSqlPrefix + instanceName + PostgreSqlSufix));
UnixSocket socket = UnixSocketChannel.open(socketAddress).socket();
return socket;
}
开发者ID:GoogleCloudPlatform,项目名称:cloud-sql-jdbc-socket-factory,代码行数:17,代码来源:SocketFactory.java
示例2: fromEnvironmentVariable
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
public static DefaultAgentProxy fromEnvironmentVariable() {
final String socketPath = System.getenv("SSH_AUTH_SOCK");
if (isNullOrEmpty(socketPath)) {
throw new RuntimeException(
"The environment variable SSH_AUTH_SOCK is not set. Please configure your ssh-agent.");
}
try {
final UnixSocketChannel channel = UnixSocketChannel.open(
new UnixSocketAddress(new File(socketPath)));
log.debug("connected to " + channel.getRemoteSocketAddress());
return new DefaultAgentProxy(new AgentInput(Channels.newInputStream(channel)),
new AgentOutput(Channels.newOutputStream(channel)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:spotify,项目名称:ssh-agent-proxy,代码行数:20,代码来源:AgentProxies.java
示例3: connectSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public Socket connectSocket(final int connectTimeout,
final Socket socket,
final HttpHost host,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpContext context) throws IOException {
try {
socket.connect(new UnixSocketAddress(socketFile), connectTimeout);
} catch (SocketTimeoutException e) {
throw new ConnectTimeoutException(e, null, remoteAddress.getAddress());
}
return socket;
}
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:16,代码来源:JSONClient.java
示例4: open
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
boolean open()
{
String pipeName = this.getTempPath() + "/discord-ipc-";
if (this.isOpen())
throw new IllegalStateException("Connection is already opened");
int pipeDigit = 0;
while (pipeDigit < 10)
{
try
{
UnixSocketAddress address = new UnixSocketAddress(pipeName + pipeDigit);
this.unixSocket = UnixSocketChannel.open(address);
this.opened = true;
return true;
}
catch (Exception ex)
{
++pipeDigit;
}
}
return false;
}
开发者ID:PSNRigner,项目名称:discord-rpc-java,代码行数:28,代码来源:BaseConnectionUnix.java
示例5: UnixDomainSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
public UnixDomainSocket(String ipcSocketPath, int bufferSize) {
this.bufferSize = bufferSize;
try {
UnixSocketAddress address = new UnixSocketAddress(ipcSocketPath);
UnixSocketChannel channel = UnixSocketChannel.open(address);
reader = new InputStreamReader(Channels.newInputStream(channel));
writer = new PrintWriter(Channels.newOutputStream(channel));
} catch (IOException e) {
throw new RuntimeException(
"Provided file socket cannot be opened: " + ipcSocketPath, e);
}
}
开发者ID:web3j,项目名称:web3j,代码行数:16,代码来源:UnixDomainSocket.java
示例6: connectSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public Socket connectSocket(
int connectTimeout,
Socket sock,
HttpHost host,
InetSocketAddress remoteAddress,
InetSocketAddress localAddress,
HttpContext context) throws IOException {
try {
sock.connect(new UnixSocketAddress(socketFile), connectTimeout);
} catch (SocketTimeoutException e) {
throw new ConnectTimeoutException(e, null, remoteAddress.getAddress());
}
return sock;
}
开发者ID:ozlerhakan,项目名称:rapid,代码行数:16,代码来源:UnixFactory.java
示例7: connect
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public void connect(final SocketAddress endpoint) throws IOException {
if (endpoint instanceof UnixSocketAddress) {
addr = endpoint;
inner.connect((UnixSocketAddress) endpoint);
setAllSocketOptions();
}
}
开发者ID:ozlerhakan,项目名称:rapid,代码行数:9,代码来源:UnixSocket.java
示例8: createSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public Socket createSocket() throws IOException {
return new JnrUnixSocket(new UnixSocketAddress(new File(path)));
}
开发者ID:fabric8io,项目名称:docker-client,代码行数:5,代码来源:UnixSocketFactory.java
示例9: JnrUnixSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
public JnrUnixSocket(UnixSocketAddress address) throws IOException {
channel = UnixSocketChannel.open();
this.address = address;
}
开发者ID:fabric8io,项目名称:docker-client,代码行数:5,代码来源:JnrUnixSocket.java
注:本文中的jnr.unixsocket.UnixSocketAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论