So I'm having this application that verifies weather a user can log-in or not.
It consists of multiple Clients (up to 200) and a server that processes the login querys (containing Username, PW and IP). The Server checks weather the user exists and sends an answer back.
TLoginQuery is a Record.
procedure TLogin_Form.btnLoginClick(Sender: TObject);
var LoginQuery1: TLoginQuery;
begin
if not LoginSocket.Active then
begin
LoginSocket.Open;
end;
//Paketchen schnüren.
LoginQuery1.Name := ledtName.Text;
LoginQuery1.Passwort := ledtPasswort.Text;
LoginQuery1.IP := LoginSocket.Socket.LocalAddress;
//LoginQuery ín den Socket legen.
LoginSocket.Socket.SendBuf(LoginQuery1, SizeOf(LoginQuery1));
end;
The Server currently reads:
procedure TServer_Form.ServerSocketClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var LoginQuery: TLoginQuery;
uservalid: boolean;
begin
uservalid := false;
Socket.ReceiveBuf(LoginQuery, SizeOf(LoginQuery));
if CheckIfUserValid(LoginQuery) then
begin
uservalid := true;
ServerSocket.Socket.SendBuf(uservalid, SizeOf(uservalid));
end;
end;
The question now is: Does the server (as it should generally be) create a different socket connection per client?
My assumption:
ClientA sends his login data and recieves the uservalid boolean (code above) from the server. As the uservalid boolean is written into the socket connection the following happens: Just before ClientA can get the uservalid boolean (as it should be) ClientB, who is already logged in, reads from the socket and gets (as it should NOT be) the uservalid boolean.
This could be intervented using one socket per client. Right?