Java高级编程9-姜国海 网络应用编程

阅读 37

2023-02-22


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();
}
}

}

服务器端

这里写代码片


精彩评论(0)

0 0 举报