history
rules
expert advice
online challenge
game source
links
test yourself
board room
the last minute
about us




Server.Java source file


import java.net.*;
import java.io.*;
import java.util.StringTokenizer;

public class Server implements Runnable{

int Cap=100;

Socket theSocket;
ServerSocket ServSock;
ServerThread client[] = new ServerThread[Cap];
boolean stillrun=true;
DataInputStream datain;
DataOutputStream dataout;
static int port = 3001;
<- replace with server port number

user Users=new user();

public void run()
{
try
{
DataInputStream inp=new DataInputStream(System.in);
String c1;
while (stillrun)
{
String comd=inp.readLine();
if (!comd.equals(""))
{
StringTokenizer tt=new StringTokenizer(comd,":");
c1=tt.nextToken();
if (c1.equals("quit"))
{
stillrun=false;
System.out.println("Server stopped !");
ServSock.close();
System.exit(0);
}
else
if (c1.equals("tell"))
Users.tellAll(tt.nextToken());
else
if (c1.equals("list"))
{
int con=0;
for (int i=0;i<=Users.nou;i++)
if (!Users.name[i].equals("None"))
{
System.out.println(Users.name[i]+" from : "+Users.adrss[i]);
con++;
};
System.out.println("No. of users : "+con);
System.out.println("");
};

};
};
}
catch (Exception e)
{System.out.println(e.toString());};
};

Server sv=new Server();

try {
sv.ServSock = new ServerSocket(sv.port);
System.out.println("Server started");
System.out.println("Server Address @ "+InetAddress.getLocalHost().toString()+" : "+sv.port);

t.start();

while (sv.stillrun) {
sv.theSocket = sv.ServSock.accept();
System.out.println("Connection accepted !");
for (g=0;g if ((sv.client[g] == null) || (!sv.client[g].isAlive()))
break;

sv.client[g] = new ServerThread(sv.theSocket,g,sv.Users);
sv.client[g].start();

}

else
System.out.println("Rejected a connection");

sv.ServSock.close();
} catch (IOException ioE){
System.out.println(" Server error ");
}
}

}

view the source file

By visiting the below links to the source code, you have agreed to our license agreement. The source codes are copyright and if you wish to use the source code or part of the engine of the game, you must obtain weiqi.com permission first. The final decision lies with weiqi.com .

Source for Board.Java

Source for Chess.Java

Source for Client.Java

Source for Server.Java

Source for ServerThread.Java

Source for User.Java

Source for Weiqi.Java

Source for WelcomeDialog.Java

top

©1999. weiqi.com Last updated on 14/08/99