Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
Creates a socket and connects it to the specified remote address on the specified remote port.
客户端
import java.net.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.io.*;
public class TClient {
public static void main(){
try{
Properties p = new Properties();
p.load(new FileInputStream("client,properties"));
Socket s = new Socket(p.getProperty("server"),
Integer.parseInt(p.getProperty("port")));
OutputStream os = s.getOutputStream();
InputStream is = s.getInputStream();
s.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
服务器端
这里写代码片