本文整理汇总了Java中jnr.unixsocket.UnixSocketChannel类的典型用法代码示例。如果您正苦于以下问题:Java UnixSocketChannel类的具体用法?Java UnixSocketChannel怎么用?Java UnixSocketChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnixSocketChannel类属于jnr.unixsocket包,在下文中一共展示了UnixSocketChannel类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSocket
import jnr.unixsocket.UnixSocketChannel; //导入依赖的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.UnixSocketChannel; //导入依赖的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: open
import jnr.unixsocket.UnixSocketChannel; //导入依赖的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;
}
示例4: UnixDomainSocket
import jnr.unixsocket.UnixSocketChannel; //导入依赖的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);
}
}
示例5: WriteBackHandler
import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
WriteBackHandler(AsynchronousSocketChannel channel, UnixSocketChannel unixSocketChannel) {
this.channel = channel;
this.unixSocketChannel = unixSocketChannel;
}
示例6: ReadHandler
import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
ReadHandler(UnixSocketChannel unixSocketChannel, AsynchronousSocketChannel channel) {
this.unixSocketChannel = unixSocketChannel;
this.channel = channel;
}
示例7: JnrUnixSocket
import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
public JnrUnixSocket(UnixSocketAddress address) throws IOException {
channel = UnixSocketChannel.open();
this.address = address;
}
示例8: UnixSocket
import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
public UnixSocket() throws IOException {
this.inner = UnixSocketChannel.open();
this.addr = null;
}