0
点赞
收藏
分享

微信扫一扫

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

}

服务器端

这里写代码片


举报

相关推荐

0 条评论