• 大小: 27KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: Java
  • 标签: java  

资源简介

java课程设计,端到端聊天系统。本课程设计使用Socket和多线程,在整体设计上分为客户端和服务器端。服务器端提供了聊天服务,客户端实现了聊天功能。

资源截图

代码片段和文件信息

package com.happy.client.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

import com.happy.common.MessageType;
import com.happy.common.ServerPort;

public class RegisterTest {
public static void main(String[] args) {
// 发送注册消息
try {
Socket client = new Socket(“127.0.0.1“
ServerPort.getREGISTER_PORT());
OutputStream os = client.getOutputStream();
PrintWriter writer = new PrintWriter(os);
BufferedReader reader = new BufferedReader(new InputStreamReader(
client.getInputStream()));
String msg = String.format(“%s%s%s%s%s“ MessageType.C_REGISTER
MessageType.SEPARATE “tomcat“ MessageType.SEPARATE
“tomcat“);
writer.println(msg);
writer.flush();
// 接收消息
String serverMsg = reader.readLine();
System.out.println(serverMsg);
writer.flush();
client.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-06-21 11:32  HappyChat\
     文件         301  2014-04-16 11:41  HappyChat\.classpath
     文件         387  2014-04-16 11:41  HappyChat\.project
     目录           0  2014-06-21 11:32  HappyChat\.settings\
     文件         598  2014-04-16 11:41  HappyChat\.settings\org.eclipse.jdt.core.prefs
     目录           0  2014-06-21 11:32  HappyChat\bin\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\client\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\client\test\
     文件        1914  2014-05-17 00:20  HappyChat\bin\com\happy\client\test\RegisterTest.class
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\common\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\common\data\
     文件        2926  2014-05-17 00:20  HappyChat\bin\com\happy\common\data\GuestDataManager.class
     文件         675  2014-05-17 00:20  HappyChat\bin\com\happy\common\data\ServerData.class
     文件        1126  2014-05-17 00:20  HappyChat\bin\com\happy\common\MessageToolTcp.class
     文件         721  2014-05-17 00:20  HappyChat\bin\com\happy\common\MessageType.class
     文件        2668  2014-05-17 00:20  HappyChat\bin\com\happy\common\ServerPort.class
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\server\
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\server\bean\
     文件         916  2014-05-17 00:20  HappyChat\bin\com\happy\server\bean\GuestBean.class
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\server\handle\
     文件        2340  2014-05-17 00:20  HappyChat\bin\com\happy\server\handle\RegisterHandle.class
     文件         683  2014-05-17 00:20  HappyChat\bin\com\happy\server\HappyChatServer.class
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\server\service\
     文件         400  2014-05-17 00:20  HappyChat\bin\com\happy\server\service\ChatListener.class
     文件         400  2014-05-17 00:20  HappyChat\bin\com\happy\server\service\ExitListener.class
     文件         403  2014-05-17 00:20  HappyChat\bin\com\happy\server\service\LoginListener.class
     文件        1773  2014-05-17 00:20  HappyChat\bin\com\happy\server\service\RegisterListener.class
     目录           0  2014-06-21 11:32  HappyChat\bin\com\happy\test\
     文件         804  2014-05-17 00:20  HappyChat\bin\com\happy\test\TestFile.class
............此处省略32个文件信息

评论

共有 条评论