Solved

delphi3 tcp

Posted on 1998-03-16
1
313 Views
Last Modified: 2011-09-20
I'm programming a client/server program and using the delphi3's component TCP. I can't get them connected. I'm being forcefully rejected. I need a example of a chat program that use this component. or somthing like that.
0
Comment
Question by:mayta8
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 60 total points
ID: 1360516
Yes, I know exactly what you have to do:

1. The TCP component is an OCX, and DELPHI includes a "isp3" in the USES clause. BUT!!! Delphi "forgets" to include ACTIVEX. Insert it manually after drawing the component to the Form.

When creating an instance of TTCP in the FORM (What you may have to) each and every client, DO remember to set it's .PARENT property (EX. TCP1.Parent:= Self), else there won't be generated any events.

Here's some examples:

Procedure ConnectButtonClick(Sender: TObject);
var
  RemoteIP: String;
Begin
  RemoteIP:= '10.0.0.7';
  TCP1.Connect(RemoteIP,TCP1.LocalPort);
End;

Procedure SendButton1Click(Sender: TObject);
var
  Data: OleVariant;
Begin
  Data:= Edit1.Text; //Edit field
  // When using ARRAYS remember to lookup TSafeArray!!!
  // OleVariants can hold almost anything.
  TCP1.SendData(Data); //
End;

procedure TForm1.TCP1ConnectionRequest(Sender: TObject;
  requestID: Integer);
begin
  //TCP1 was in listen-mode, when generating this event
  TCP2.Accept(requestID); //You need to hand the requestID to another instance of TTCP!
  ShowMessage('Request received from '+TCP1.RemoteHostIP);
  TCP1.Close;
  TCP1.Listen;
end;

procedure TForm1.TCP2DataArrival(Sender: TObject; bytesTotal: Integer);
var
  Data: OleVariant;
Begin
  TCP2.GetData(Data, VT_BSTR,BytesTotal);
  Memo1.Lines.Add(Data);
end;

procedure ResetButtonClick(Sender: TObject);
Begin
  TCP1.Close;
  TCP2.Close;
  TCP1.Listen;
End;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to renew a Delphi rad-studio licence? 5 49
Multiple image collision 13 69
can't find the executable in Simulator 1 80
how to update exe applicatio from internet ? 6 69
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now