Я изучаю программирование сокетов, и пример в книге показывает:Почему клиентский сокет принимает localhost как параметр?
// SimpleClient.java: A simple client program.
import java.net.*;
import java.io.*;
public class SimpleClient {
public static void main(String args[]) throws IOException {
// Open your connection to a server, at port 1254
Socket s1 = new Socket(“localhost”,1254);
// Get an input file handle from the socket and read the input
InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
String st = new String (dis.readUTF());
System.out.println(st);
// When done, just close the connection and exit
dis.close();
s1In.close();
s1.close();
}
}
Мой вопрос заключается в том, что на линии нового сокете («локальный», 1254), поэтому адрес является локальным, а не IP сервером адрес?
Поскольку сервер должен работать в локальном хосте. – EJP