Home > other >  Two clients how to send each other information through the server
Two clients how to send each other information through the server

Time:10-04

A novice asked the great spirit

CodePudding user response:

To a great god help solve

CodePudding user response:

C/S structure, unlimited number of Clients
[structure]
Define the message structure, such as the recipient, the message body, news of additional style, etc.
Define the client identification rules: IP + port
Define the client registration processes: login request data structures, such as pet name/ID
Define the Client data: nickname/ID - IP + port key-value pairs, Client data structure (IP, port, nickname, landing time, also can see demand do history)
(server)
Fixed port to listen;
Maintain the client list: increase after the new client connection, the client after disconnecting from the list to remove
Receive messages: custom message format, such as JSON, XML, PLAIN text, messages can be divided into the recipient and message body two parts (can be extended on the basis of this, the individuality signature, for example, style of writing paper, etc.)
Forwarded message, the main execution after receiving, according to judge who should be forwarded to the message recipient section, then the message body intact to correspond to the client,

Client:
Register/login identity;
Send the message, message is divided into the recipient, the message body;
Receives the message (if it is expanding a message structure, according to the extension information to show message);
Optional: read receipt, real-time input state,

CodePudding user response:

In doing this, doing simple

First of all establish the connection between the server and client communication SOCKET

Chat client to the server sends the request, the server is the news announcements for all in the connection of the client,

The client through the message signed judgment of his hair, hair or others, show that,

CodePudding user response:

Watch

CodePudding user response:

This is very simple, you can pass each other through the software in the local area network (LAN), or chat, of course, only local area network (LAN), such as: fly autumn, fly autumn can make the two clients how to send each other information, through the server

If a LAN phone, this can refer to the silver of guangzhou - optical transceiver at http://www.gzyinxun.com/Products/3000/
  • Related