You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
import java.net.*;
|
|
import java.io.*;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.regex.Pattern;
|
|
|
|
public class ctServer {
|
|
// public static int socketID;
|
|
// public static ArrayList<socketInfo> socketInfoList;
|
|
|
|
|
|
public static boolean checkClient(socketInfo socketID, String[] args){
|
|
/*
|
|
socketInfo flow = new socketInfo();
|
|
//TODO: Устарело
|
|
//TODO: перенести в console.java
|
|
try {
|
|
for (String name : args) {
|
|
Pattern main = Pattern.compile(":");
|
|
String[] sx = main.split(name);
|
|
switch (sx[0]) {
|
|
case "PROTOCOL":
|
|
flow.PROTOCOL = sx[1];
|
|
break;
|
|
case "VKID":
|
|
flow.VKID = sx[1];
|
|
break;
|
|
}
|
|
}
|
|
if (!flow.VKID.equals("")) {
|
|
if (!flow.PROTOCOL.equals("")) {
|
|
flow.httpAuth = true;
|
|
socketInfoList.set(flow.SOCKETID, flow);
|
|
console.debug("Авторизация произошла!");
|
|
return true;
|
|
}
|
|
}
|
|
} catch (NullPointerException e){
|
|
return false;
|
|
}finally {
|
|
flow.close();
|
|
System.gc();
|
|
}
|
|
*/
|
|
return false;
|
|
}
|
|
|
|
public static void main(String[] args) throws IOException{
|
|
socketInfo.init();
|
|
// socketID = 0;
|
|
try{
|
|
new console().consoleListner();
|
|
}
|
|
catch (IOException e){
|
|
|
|
}
|
|
int port = 80;
|
|
console.out("Socket Port", port+"");
|
|
ServerSocket ss = new ServerSocket(port);
|
|
try {
|
|
console.out("Server", "Waiting for a client");
|
|
while(true) {
|
|
Socket socket = ss.accept();
|
|
try {
|
|
new client().openSocket(socket);
|
|
} catch (IOException e) {
|
|
socket.close();
|
|
}
|
|
}
|
|
} finally {
|
|
ss.close();
|
|
}
|
|
}
|
|
|
|
}
|