Board index » delphi » Cant send msg with tcpclient??

Cant send msg with tcpclient??

Hi all,

I have an app with 2 forms. The main form has the TCPClient component on it.
There is also a function that sends a message to the server and returns the
result (ignore any code inelegancies, its just a test) :

function TFrmMain.MsgSendAndWait(sMessage : string) : string;
begin
  try
    frmMain.MsgClient.Connect;
    frmMain.MsgClient.WriteLn(sMessage);
    try
      Result := frmMain.MsgClient.ReadLn;
    finally
      frmMain.MsgClient.Disconnect;
    end;
  except
    on EIDSocketError do
      begin
        Result := 'ERROR';
      end;
  end;
end;

If I use this function from the main form to send messages to the server,
everything works perfectly. If I try to call this function from the second
form, the message never gets through to the server, and nothing is
returned....

Any ideas, this is driving me insane :) ???

Cheers,

Doc

 

Re:Cant send msg with tcpclient??


Quote
> If I use this function from the main form to send messages to the server,
> everything works perfectly. If I try to call this function from the second
> form, the message never gets through to the server, and nothing is
> returned....

Has the client on the second form the same properties as the client on the
first form?

Also: Use "MsgClient.xxx" instead of "frmMain.MsgClient.xxx" !

Helge.

Other Threads