• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UnixSocketChannel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:GoogleCloudPlatform,项目名称:cloud-sql-jdbc-socket-factory,代码行数:17,代码来源:SocketFactory.java


示例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);
  }
}
 
开发者ID:spotify,项目名称:ssh-agent-proxy,代码行数:20,代码来源:AgentProxies.java


示例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;
}
 
开发者ID:PSNRigner,项目名称:discord-rpc-java,代码行数:28,代码来源:BaseConnectionUnix.java


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


示例5: WriteBackHandler

import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
WriteBackHandler(AsynchronousSocketChannel channel, UnixSocketChannel unixSocketChannel) {
    this.channel = channel;
    this.unixSocketChannel = unixSocketChannel;
}
 
开发者ID:wallezhang,项目名称:portainer-agent,代码行数:5,代码来源:WriteBackHandler.java


示例6: ReadHandler

import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
ReadHandler(UnixSocketChannel unixSocketChannel, AsynchronousSocketChannel channel) {
    this.unixSocketChannel = unixSocketChannel;
    this.channel = channel;
}
 
开发者ID:wallezhang,项目名称:portainer-agent,代码行数:5,代码来源:ReadHandler.java


示例7: JnrUnixSocket

import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
public JnrUnixSocket(UnixSocketAddress address) throws IOException {
    channel = UnixSocketChannel.open();
    this.address = address;
}
 
开发者ID:fabric8io,项目名称:docker-client,代码行数:5,代码来源:JnrUnixSocket.java


示例8: UnixSocket

import jnr.unixsocket.UnixSocketChannel; //导入依赖的package包/类
public UnixSocket() throws IOException {
    this.inner = UnixSocketChannel.open();
    this.addr = null;
}
 
开发者ID:ozlerhakan,项目名称:rapid,代码行数:5,代码来源:UnixSocket.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RevisionNumber类代码示例发布时间:2022-05-22
下一篇:
Java GrowableIntArray类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap