本文整理汇总了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();
}
示例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;
}
示例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());
}
}
示例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;
}