返回列表 发帖
搬东西~~搬过来又让你搬回去??谁这么缺德???!!!

哈哈~~

TOP

搬东西~~搬过来又让你搬回去??谁这么缺德???!!!

哈哈~~

TOP

.....郁闷了~~我发一下~~网卡点了N次,结果发了这么多次~~

TOP

汗楼上的…………

TOP

1sa,2005-05-29, 02:09:27
package sf;

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

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright &copy; 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/


public class sf {
  final int PORT = 15100;
  public sf() {
    ServerSocket sfServer = null;
    Socket sfClient = null;
    ServerThread sfThread = null;
    try {
      sfServer = new ServerSocket(PORT);
      System.out.println("Server is listening...";
      while (true) {
        sfClient = sfServer.accept();
        sfThread = new ServerThread(sfClient);
        sfThread.start();
      }
    } catch (IOException e) {
      System.out.println(e.getMessage());
    }
  }

  public static void main(String args[]) {
    new sf();
  }
}


class ServerThread extends Thread {
  Socket sfClient = null;

  BufferedInputStream input = null;
  DataOutputStream output = null;

  byte[] receiveBuffer;
  int len;
  String code;
  int receiveCommand;

  byte[] replyBuffer;
  int pos;
  int replyCommand;

  int channel;

  private static final int unknownCommand = 0;
  private static final String serverUrl = "127.0.0.1";
  private static final int serverPort = 15100;
  private static final String webUrl = "127.0.0.1:80";

  String userName = "Esa";
  String userPass = null;
  int userSex = 1; //1为男 0为女
  long userMoney = 100000;
  int userLevel = 100;
  int userAllTurn = 0;
  int userWinTurn = 0;
  int userLoseTurn = 0;
  long userExperience = 100000;
  int userCloth = 0x5b; //0x4f~0x5b
  int userTrousers = 0x6c; //0x6a~0x77
  int userShoes = 0x78;
  int userHead = 0x23;

  String roomName = null;
  static int roomNum = 0;

  public ServerThread(Socket sfClient) {
    this.sfClient = sfClient;
    System.out.println("a new thread...";
    try {
      input = new BufferedInputStream(sfClient.getInputStream());
      output = new DataOutputStream(sfClient.getOutputStream());
    } catch (IOException e) {
      System.out.println(e.getMessage());
      return;
    }
  }

  public void run() {
    boolean done = false;
    while (!done) {
      try {
        receiveBuffer = new byte[20480];
        len = input.read(receiveBuffer);
        code = new String(receiveBuffer, 0, len);
        receiveCommand = receiveBuffer[3] * 256 + receiveBuffer[2];
        replyBuffer = new byte[20480];
        pos = 4;System.out.println(receiveCommand);
        switch (receiveCommand) { //所有的>256的command,比真实值小256
        case 0x0000:
          replyCommand = 1; //返回版本信息
          doUpdateServer();
          break;
        case 0x0004:
          replyCommand = 5; //未知命令
          doUnknow0x004Server();
          break;
        case 0x0002:
          replyCommand = 3; //返回空的新闻http页面
          doPatchServer();
          break;
        case 0x0009:
          replyCommand = 0x000a; //返回服务器列表
          doServerListServer();
          output.write(replyBuffer, 0, pos);
          output.flush();
          output.close();
          sfClient.close();
          return;
                case 0x02f1:
           replyCommand=0x03f2;
           doUnknown0x03f1Server();
                   break;
        case 0x02ef:
          replyCommand = 0x03f0; //告知密码验证成功,发送验证码
          doCheckPassServer();
          break;
        case -272: //让客户端关闭一个TCP连接

呵呵!
很高深阿@@|||

新版本阿...會爆jam combo就好嚕-v-...

體力勞動多了要不要找我們兄弟幫手阿

TOP

wilkinsho,2005-05-30, 23:01:10
[QUOTE]1sa,2005-05-29, 02:09:27
package sf;

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

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright &copy; 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/


public class sf {
  final int PORT = 15100;
  public sf() {
    ServerSocket sfServer = null;
    Socket sfClient = null;
    ServerThread sfThread = null;
    try {
      sfServer = new ServerSocket(PORT);
      System.out.println("Server is listening...";
      while (true) {
        sfClient = sfServer.accept();
        sfThread = new ServerThread(sfClient);
        sfThread.start();
      }
    } catch (IOException e) {
      System.out.println(e.getMessage());
    }
  }

  public static void main(String args[]) {
    new sf();
  }
}


class ServerThread extends Thread {
  Socket sfClient = null;

  BufferedInputStream input = null;
  DataOutputStream output = null;

  byte[] receiveBuffer;
  int len;
  String code;
  int receiveCommand;

  byte[] replyBuffer;
  int pos;
  int replyCommand;

  int channel;

  private static final int unknownCommand = 0;
  private static final String serverUrl = "127.0.0.1";
  private static final int serverPort = 15100;
  private static final String webUrl = "127.0.0.1:80";

  String userName = "Esa";
  String userPass = null;
  int userSex = 1; //1为男 0为女
  long userMoney = 100000;
  int userLevel = 100;
  int userAllTurn = 0;
  int userWinTurn = 0;
  int userLoseTurn = 0;
  long userExperience = 100000;
  int userCloth = 0x5b; //0x4f~0x5b
  int userTrousers = 0x6c; //0x6a~0x77
  int userShoes = 0x78;
  int userHead = 0x23;

  String roomName = null;
  static int roomNum = 0;

  public ServerThread(Socket sfClient) {
    this.sfClient = sfClient;
    System.out.println("a new thread...";
    try {
      input = new BufferedInputStream(sfClient.getInputStream());
      output = new DataOutputStream(sfClient.getOutputStream());
    } catch (IOException e) {
      System.out.println(e.getMessage());
      return;
    }
  }

  public void run() {
    boolean done = false;
    while (!done) {
      try {
        receiveBuffer = new byte[20480];
        len = input.read(receiveBuffer);
        code = new String(receiveBuffer, 0, len);
        receiveCommand = receiveBuffer[3] * 256 + receiveBuffer[2];
        replyBuffer = new byte[20480];
        pos = 4;System.out.println(receiveCommand);
        switch (receiveCommand) { //所有的>256的command,比真实值小256
        case 0x0000:
          replyCommand = 1; //返回版本信息
          doUpdateServer();
          break;
        case 0x0004:
          replyCommand = 5; //未知命令
          doUnknow0x004Server();
          break;
        case 0x0002:
          replyCommand = 3; //返回空的新闻http页面
          doPatchServer();
          break;
        case 0x0009:
          replyCommand = 0x000a; //返回服务器列表
          doServerListServer();
          output.write(replyBuffer, 0, pos);
          output.flush();
          output.close();
          sfClient.close();
          return;
&nbsp; case 0x02f1:
           replyCommand=0x03f2;
           doUnknown0x03f1Server();
&nbsp;    break;
        case 0x02ef:
          replyCommand = 0x03f0; //告知密码验证成功,发送验证码
          doCheckPassServer();
          break;
        case -272: //让客户端关闭一个TCP连接

呵呵!
很高深阿@@|||

新版本阿...會爆jam combo就好嚕-v-...

體力勞動多了要不要找我們兄弟幫手阿 [/QUOTE]
这个^^^

TOP

新版本会有什么改变呢?好期待啊~~~~~
还有,请问fancyzero同志是学生吗??我想加你的QQ,我有点崇拜你了

TOP

返回列表