Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Apr : tcpcmdserver/tcpclient problem -D7/indy10.0.52

www.cryer.info
Managed Newsgroup Archive

tcpcmdserver/tcpclient problem -D7/indy10.0.52

Subject:tcpcmdserver/tcpclient problem -D7/indy10.0.52
Posted by:"Hendrick" (hen..@hotmail.com)
Date:8 Apr 2005 17:36:43

I have several problems using the above components:

On Serverside:
1. at run time when a client disconncets from server i get this error: "Invalid pointer operation" The ondisconnect event is:
tcpserver.disconnect;

2. Is that i do not know how to use the reply codes. Is the codes for command handlers different from the main, component's reply code?

3. How do i send a msg to the client when they connect(A greeting or something like that)? And what code is used to recieve the message on the client side?

Clientside:

4. If i want to send a cmd, what code do i use to get the response from the server? the code i have is:

client.SendCmd(edit1.Text,200);
memo1.Lines.add(client.IOHandler.ReadLn);

The above code seems to crash the client. basically nothing happens when i press the send button, and when i press it again, it crash. What could i possibly be doing wrong?

Here's the entire code for my program:

Server code
procedure TForm1.FormCreate(Sender: TObject);
begin
serv.Active:=true;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
serv.Active:=false;
end;

procedure TForm1.servConnect(AContext: TIdContext);
begin
//send greeting msg when client connects
????
end;

procedure TForm1.servHelperCommand(ASender: TIdCommand);
begin
asender.Reply.SetReply(200, 'Server X responds to the following commands1:');
asender.Reply.SetReply(200, 'Getfile');
asender.Reply.SetReply(200, 'Help');
asender.Reply.SetReply(200, 'Quit');
asender.Reply.SetReply(200, 'Hello');
asender.Reply.SetReply(200, 'Myname');


end;

procedure TForm1.servDisconnect(AContext: TIdContext);
begin
serv.Active:=false;
end;

end.

Client:

procedure TForm1.Button1Click(Sender: TObject);
begin
client.Connect;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
client.Disconnect;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
client.SendCmd(edit1.Text,200);
memo1.Lines.add(client.IOHandler.ReadLn);
end;

procedure TForm1.clientConnected(Sender: TObject);
begin
memo1.Lines.Add(client.LastCmdResult.Text.Text)
end;

end.

I know it's alot of questions, so thank you all in advance

Replies:

www.cryer.info
Managed Newsgroup Archive