[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

delphi3 tcp

Posted on 1998-03-16
1
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 240 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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