Хелп посмотри - там даже пример есть события OnRead если нет хелпа:(+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено vvv 10 июня 2004 г. 20:06
В ответ на: Ответ: отправлено patton 10 июня 2004 г. 18:06

Declaration

property OnRead: TNotifyEvent;

Description

The OnRead event is called when there is incoming data being sent from the remote host. This corresponds to WinSock's FD_READ message.

Notes:

The OnRead event is where you would use the read, readln, and other data-retrieving methods to get data from the remote host as it comes in.
//================================
Drop a TButton, a TMemo, and a TPowersock on the form.

In the OnClick event for the TButton, insert the following code:

void __fastcall TForm1::Button1Click(TObject *Sender)

{

Powersock1->Host = "www.netmastersllc.com";

Powersock1->Port = 13;

Powersock1->Connect();

}

In the OnConnect event for the TPowersock control, insert the following code:

void __fastcall TForm1::Powersock1Connect(TObject *Sender)

{

Memo1->Liens->Add("Connected");

Memo1->Lines->Add("Local Address: "+Powersock1->LocalIP);

Memo1->Lines->Add("Remote Address: "+Powersock1->RemoteIP);

}

In the OnHostResolved event for the TPowersock control, insert the following code:

void __fastcall TForm1::Powersock1HostResolved(TComponent *Sender)

{

Memo1->Lines->Add("Host Resolved");

}

In the OnStatus event for the TPowersock control, insert the following code:

void __fastcall TForm1::Powersock1Status(TComponent *Sender, AnsiString Status)

{

Memo1->Lines->Add(Powersock1->Status);

Memo1->Lines->Add("Last WinSock error: "+IntToStr(Powersock1->LastErrorNo));

if (Powersock1->BeenCanceled)

Memo1->Lines->Add("Input/ouput operation canceled");

if (Powersock1->BeenTimedOut)

Memo1->Lines->Add("Operation timed out");

}

Example Description:

Run the application, and then click Button1.

When Button1 is clicked, a connection is established with www.netmastersllc.com on port 13. Once www.netmastersllc.com has been resolved to a valid IP address, the OnHostResolved event will state that fact by adding a line to Memo1. When the connection is established, the OnConnect event updates the Memo1 to inform the user that a connection has been established. Also, the dotted IP address of the local machine, the LocalIP property, is added to Memo1, in addition to the IP address of the remote computer, the RemoteIP property. As status messages are available, they are added to Memo1's lines, as well as the last Winsock error encountered. If the current operation has been canceled, the BeenCanceled property will be TRUE, and the cancellation will be displayed in Memo1. If the current operation has timed out, the BeenTimedOut property will be True, and a timeout message will be added to Memo1.

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru