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

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

}

服务器端

这里写代码片
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页