Solved

delphi3 tcp

Posted on 1998-03-16
1
317 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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