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


Java NetUtils.getLoopbackAddress方法代码示例

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


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

示例1: writeLine

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@SuppressWarnings({"SocketOpenedButNotSafelyClosed", "IOResourceOpenedButNotSafelyClosed"})
private synchronized void writeLine(@NonNls final String s) {
  if (myWriter == null) {
    try {
      if (mySocket == null) {
        mySocket = new Socket(NetUtils.getLoopbackAddress(), myPortNumber);
      }
      myWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(mySocket.getOutputStream())));
    }
    catch (IOException e) {
      return;
    }
  }
  myWriter.println(s);
  myWriter.flush();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ProcessProxyImpl.java

示例2: createSocket

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@NotNull
private Socket createSocket() throws IOException {
  InetAddress host = myHost;
  if (host == null) {
    try {
      host = InetAddress.getLocalHost();
    }
    catch (UnknownHostException ignored) {
      host = NetUtils.getLoopbackAddress();
    }
  }

  IOException exc = null;
  for (int i = 0; i < myPortsNumberToTry; i++) {
    int port = myInitialPort + i;
    try {
      return new Socket(host, port);
    }
    catch (IOException e) {
      exc = e;
      LOG.debug(e);
    }
  }
  throw exc;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SocketConnectionImpl.java

示例3: computeDebugAddress

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@NotNull
@Override
public InetSocketAddress computeDebugAddress() {
  if (host == null) {
    return new InetSocketAddress(NetUtils.getLoopbackAddress(), port);
  }
  else {
    return new InetSocketAddress(host, getPort());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:RemoteDebugConfiguration.java

示例4: connect

import com.intellij.util.net.NetUtils; //导入方法依赖的package包/类
@Nullable
private InputStream connect(int port) throws IOException {
    final long s = System.currentTimeMillis();
    final InetSocketAddress endpoint = new InetSocketAddress(NetUtils.getLoopbackAddress(), port);

    myStartedProcess.notifyTextAvailable("Connecting to XSLT runner on " + endpoint + "\n", ProcessOutputTypes.SYSTEM);

    int tries = 0;
    IOException ex;
    do {
        final int d = (int)(System.currentTimeMillis() - s);
        try {
            @SuppressWarnings({"SocketOpenedButNotSafelyClosed"})
            final Socket socket = new Socket();
            socket.connect(endpoint, Math.max(CONNECT_TIMEOUT - d, 100));

            myStartedProcess.notifyTextAvailable("Connected to XSLT runner." + "\n", ProcessOutputTypes.SYSTEM);
            return socket.getInputStream();
        } catch (ConnectException e) {
            ex = e;
            try { Thread.sleep(500); } catch (InterruptedException ignored) { break; }
        }
        if (myStartedProcess.isProcessTerminated() || myStartedProcess.isProcessTerminating()) {
            return null;
        }
    } while (tries++ < 10);

    throw ex;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:OutputTabAdapter.java


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