本文整理汇总了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;
}
示例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);
}
}
示例3: 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();
}
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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;
}
示例8: createSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
@Override
public Socket createSocket() throws IOException {
return new JnrUnixSocket(new UnixSocketAddress(new File(path)));
}
示例9: JnrUnixSocket
import jnr.unixsocket.UnixSocketAddress; //导入依赖的package包/类
public JnrUnixSocket(UnixSocketAddress address) throws IOException {
channel = UnixSocketChannel.open();
this.address = address;
}