当前位置:网站首页>104. simple chat room 7: use socket to transfer objects

104. simple chat room 7: use socket to transfer objects

2022-06-23 05:34:00 Jasonakeke

Title Description

Topic realization : When using network programming , Need to pass through Socket Transfer object .

Their thinking

Create a class :Employee, Implement serialization

Employee Class contains two properties and their corresponding get() and set() Method

Create a server class :ServerSocketFrame, Inherit JFrame class

Write a getServer() Method , Instantiation Socket object , Enable 9527 When the port of the service .

Create an input stream object , Used to receive client information .

Let me define one more getClientInfo() Method , Used to receive information sent by the client .

Add an event to the text box : Realize sending weighing information to the client .

Create a client class :ClientSocketFrame, Inherit JFrame class .

Write a connect() Method , Instantiation Socket object , Connect to the local service 9527 Port services .

Let me define one more getClientInfo() Method , Used to receive information sent by the server .

Technical focus :

stay Java Use in Socket When passing objects , The object must be serialized , stay Java To realize Serializable The class of the interface , The created object is the serialized object , Can pass Sock

原网站

版权声明
本文为[Jasonakeke]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230211442854.html