Skip to content

Commit

Permalink
Explicitly use localhost on server socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Jun 17, 2020
1 parent 01573df commit c259f6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -1673,7 +1674,7 @@ public static VirtualMachine attach(String processId, int timeout, Dispatcher di
if (target == null) {
throw new IllegalStateException("Could not locate target process info in " + directory);
}
ServerSocket serverSocket = new ServerSocket(0);
ServerSocket serverSocket = new ServerSocket(0, 1, InetAddress.getLocalHost());
try {
serverSocket.setSoTimeout(timeout);
File receiver = new File(directory, target.getProperty("vmId"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.*;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Arrays;
Expand Down Expand Up @@ -89,7 +90,7 @@ public void run() {
}
Socket socket = new Socket();
try {
socket.connect(new InetSocketAddress(port), 5000);
socket.connect(new InetSocketAddress(InetAddress.getLocalHost(), port), 5000);
socket.getOutputStream().write((' ' + key + ' ').getBytes("UTF-8"));
socket.getOutputStream().write(0);
socket.getOutputStream().flush();
Expand Down

0 comments on commit c259f6e

Please sign in to comment.