Home > Back-end >  The socket pushed corresponding user problems
The socket pushed corresponding user problems

Time:09-26

Program features: web side through the socket TCP keep communication with the server, for server returns information,
Information is divided into two parts (1, the service side take the initiative to push the data of 2, web client requested data)
At present under the condition of multiple users online at the same time, the service side take the initiative to push the data of every user can receive, but the request data problems, help,
1, the service side take the initiative to push the data - normal
A user login web front-end (IP, PORT, user name, password) - the background (receive data server push, sent to the front) ", "the service side (active push data)
B: user login web front-end (IP, PORT, user name, password) - the background (receive data server push, sent to the front) ", "the service side (active push data)
C: user login web front-end (IP, PORT, user name, password) - the background (receive data server push, sent to the front) ", "the service side (active push data)
Different users of different ports, socket=new socket (host, port);
2, web client request is a problem with the data -
All users have been under the premise of the login, the login time. A, B, C
User: A web front-end (data request) - the background (send request packets to the service side, waiting for the server returned data) ", "the service side (push)
B users: web front-end data (request), the background (send request packets to the service side, waiting for the server returned data) "--" the server-side data (push)
C users: web front-end data (request), the background (send request packets to the service side, waiting for the server returned data) "--" the server-side data (push)

B users to send data request, for example, then the server can send data, but found that the user is not B received data, but C users received,
By check socket information found in the idea is C user, A user testing is also the situation, feeling should be the socket in the call the last login user C,
System. The out. Println (" socket information view: "+ socket);

Supplement: the server is somebody else's program, can't change,

How to solve this kind of circumstance, thank you!!!!!
  • Related