当前位置:网站首页>103.简易聊天室6:使用 Socket 通信
103.简易聊天室6:使用 Socket 通信
2022-06-22 04:24:00 【Jasonakeke】
题目描述
题目实现:使用套接字实现了服务器端与客户端的通信。
运行程序,在服务器端的文本框中输入信息,然后按回车键,客户端就会收到服务器端发送的信息;
在客户端的文本框中输入信息,然后按回车键,服务器端就会收到客户端发送的信息,发送信息后的效果。
解题思路
创建一个服务器类:ServerSocketFrame,继承 JFrame 类
写一个 getserver() 方法,实例化 Socket 对象,启用9527当服务的端口。
创建输入流对象,用来接收客户端信息。
再定义一个 getClientInfo() 方法,用于接收客户端发送的信息。
对文本框添加一个事件:实现向客户端发磅信息。
创建一个客户端类:ClientSocketFrame,继承 JFrame 类。
写一个 connect() 方法,实例化 Socket 对象,连接本地服务的9527端口服务。
再定义一个 getClientInfo() 方法,用于接收服务端发送的信息。
技术重点:
通过 Socket 类的 getInpuStream() 方法来获得输入流对象,并借助 InputStream
边栏推荐
- With this set of templates, it is easier to play with weekly, monthly and annual reports
- Sequential implementation of queues
- 二叉树线索化
- Daily question: the difference between ArrayList and LinkedList
- nest. Module dependency transitivity in JS practice
- POSIX shared memory
- Active learning overview, strategy and uncertainty measurement
- CentOS uses composer install to report an error - phpunitphppunit 8
- 积加ERP全局参数灵活配置成本取值规则,核算全面到位
- IDEA蓝屏的解决方案
猜你喜欢

Raspberry pie preliminary use

Odoo Development Manual (I) the second day of contact with odoo

Django learning - model and database operation (II)

IDEA蓝屏的解决方案

Is the first woman coming to the 3A mobile game? Recognized by IGN, can "in shining name" stand out from the encirclement

When the move protocol beta is in progress, the ecological core equity Momo is divided

线索二叉树

"Defi moral paradox" behind solend farce

Accumulate ERP global parameters, flexibly configure cost value rules, and complete accounting
![Chapter VIII programmable interface chip and application [microcomputer principle]](/img/63/5f01a74defd60f0d4a8f085ff0e2e9.png)
Chapter VIII programmable interface chip and application [microcomputer principle]
随机推荐
【shell】1加到100的方法
Join waits for synchronization results from multiple threads
Cordova 项目中自定义插件--插件创建流程
Is it safe to open an account in Guoyuan futures?
队列的顺序实现
Search (intensive training)
With these websites, do you still worry about job hopping without raising your salary?
低功耗雷达感应模组,智能锁雷达感应方案应用,智能雷达传感器技术
Idea blue screen solution
With this set of templates, it is easier to play with weekly, monthly and annual reports
[Niu Ke's questions -sql big factory interview questions] no1 An audio short video
fc2新域名有什么价值?如何解析到网站?
树莓派初步使用
How to write a detailed and professional software function test report
Introduction to AWS elastic Beanstalk
Use of markdown markup language
Sequential implementation of queues
有了这几个刷题网站,还愁跳槽不涨薪?
CAPL学习之路-以太网函数
哈夫曼树