展开全部
package com.cep.usercenter.sys;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class RunUserCenterSystem {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(51818);
while (true) {
Socket socket = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String line = in.readLine();
if("stop".trim().equalsIgnoreCase(line)){
if(ctx != null){
ctx.stop();
ctx.close();
System.exit(0);
}
}else{
System.out.println("接收的数据为: "+line);
}
in.close();
socket.close();
}
} catch (Exception e) {
}
}
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class RunUserCenterSystem {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(51818);
while (true) {
Socket socket = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String line = in.readLine();
if("stop".trim().equalsIgnoreCase(line)){
if(ctx != null){
ctx.stop();
ctx.close();
System.exit(0);
}
}else{
System.out.println("接收的数据为: "+line);
}
in.close();
socket.close();
}
} catch (Exception e) {
}
}
}
追问
if(ctx != null)
ctx是什么?没看到有定义
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询