Im gonna try to explain my problem:
i got 2 exe's (Client and server).
the client application sends strings to the server on button click and write the server response to a memo.
the server application gets client strings and sends back a message saying "Recebido".
When i start the client (with the server app already running) i get the message from server saying "Recebido", and when i send a message clicking the button the server sends the "Recebido" message. my problem is : when i send some string to the server again, the client doesnt write anything to the memo. i dunno if it is client or server's problem. here is the code of the client:
Code:
unit Cliente;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
Cliente: TClientSocket;
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ClienteRead(Sender: TObject; Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Cliente.Socket.SendText(Edit1.Text);
end;
procedure TForm1.ClienteRead(Sender: TObject; Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(Socket.ReceiveText);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Cliente.Open;
end;
end.
and the server's:
Code:
unit Servidor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp;
type
TForm1 = class(TForm)
Servidor: TServerSocket;
procedure ServidorClientRead(Sender: TObject; Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
procedure ServidorAccept(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ServidorClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Servidor.Socket.Connections[0].SendText('Recebido');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Servidor.Active := True;
end;
procedure TForm1.ServidorAccept(Sender: TObject; Socket: TCustomWinSocket);
begin
Servidor.Socket.Connections[0].SendText('Recebido');
end;
end.
help me please
