当前位置:网站首页>110. 简易聊天室13:聊天室服务端
110. 简易聊天室13:聊天室服务端
2022-06-29 01:52:00 【Jasonakeke】
题目描述
题目实现:实现聊天室服务器端功能。运行程序,服务端等待客户端连接,并显示客户端的连接信息。
解题思路
创建一个服务类:ChatServerFrame,继承JFrame类
定义一个Hashtable对象,用于存储登录用户的用户名和套接字对象。
定义createSocket()方法,用于创建服务器套接字对象、获得连接到服务器的客户端套接字对象以及启动线程对象对客户端发送的信息进行处理。
定义内部线程类ServerThread用于对客户端的连接信息以及发送的信息进行处理和转发。
技术重点:
本实例使用Hashtable类来存储连接到服务器的用户名和套接字对象,并使用String类的 startWith()方法判断客户端发送信息的类型,从而实现了向服务器端添加登录用户、发送退出信息、通过服务器转发客户端发送的信息等功能,最终完成了聊天室服务器端程序的开发。
代码详解
package question;
边栏推荐
- Callback function of unity after importing resources
- When you complain about the roll, others have quietly begun to prepare for the golden three silver four
- The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser
- 【内网穿透】Frp 自建跳板-两个内网通讯上线-反弹shell
- Fibonacci sequence
- mysql数据库修改密码
- 为什么建议大家尽可能选择自研公司
- Research on VB multi-layer firewall technology - state detection
- AHA C language, C language programming introductory books and PPT (PDF version) download website
- How to prevent virus
猜你喜欢

How to use PN junction to measure temperature?

In simple terms, server intrusion prevention

Callback function of unity after importing resources

The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser

C language course design - food warehouse management system
![[机缘参悟-33]:眼见不一定为实,大多数时候“眼见为虚”](/img/60/703a5bc3038d28bcf812415032f240.jpg)
[机缘参悟-33]:眼见不一定为实,大多数时候“眼见为虚”

Uniapp notes

4276. good at C
Scala Foundation (3): Operators and Process Control

Rasa对话机器人之HelpDesk (五)
随机推荐
OculusRiftS与Unity.UI的交互(1)-总览
Similarities and differences between SRAM and DRAM
TypeScript(4)接口
RISC CPU design based on FPGA (4) 36 questions about the project and their answers
Tiflash compiler oriented automatic vectorization acceleration
Necessary technologies for chip manufacturers (1) Introduction
Callback function of unity after importing resources
PR FAQ: how to retrieve accidentally deleted video and audio in PR?
With this tool, automatic identification and verification code is no longer a problem
How to become a senior digital IC Design Engineer (6-4) digital IC Verification: test point decomposition
[solution] longest common subsequence
How to prevent virus
Basic use of Sqlalchemy
想请教一下,我在中山,到哪里开户比较好?在线开户是安全么?
TypeScript(5)类、继承、多态
The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser
What is stock online account opening? Is it safe to open an account online?
SAP ui5 beginner tutorial 24 - how to use OData data model
TypeScript(6)函数
How to use PN junction to measure temperature?