服务器是怎么连接java程序的
答案:1 悬赏:60 手机版
解决时间 2021-02-26 01:12
- 提问者网友:了了无期
- 2021-02-25 07:49
服务器是怎么连接java程序的
最佳答案
- 五星知识达人网友:渡鹤影
- 2021-02-25 08:37
用Socket类去连接
String ip = "192.168.0.57";
int port=7000;
InputStream in;
OutputStream out;
Socket sock = null;
try {
sock = new Socket(ip,port);
sock.setSoTimeout(60*1000);//设置超时
this.in = sock.getInputStream();
this.out = sock.getOutputStream();
} catch (Exception e) {
throw new Exception("与终端连接失败!");
}
String ip = "192.168.0.57";
int port=7000;
InputStream in;
OutputStream out;
Socket sock = null;
try {
sock = new Socket(ip,port);
sock.setSoTimeout(60*1000);//设置超时
this.in = sock.getInputStream();
this.out = sock.getOutputStream();
} catch (Exception e) {
throw new Exception("与终端连接失败!");
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯