請問 IdIPMCastClient 和 IdIPMCastServer |
答題得分者是:流
|
Kboy
一般會員 發表:1 回覆:3 積分:0 註冊:2003-08-01 發送簡訊給我 |
有人使用過這個元件嗎?
能否可以給我個範例,pascal的也行...謝謝...
我自己以一個jpg檔在本機測試時,好像都收不到.. 以下是我的程式:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Memo1->Clear();
IdIPMCastClient1->Active = true;
if(IdIPMCastClient1->Active)
Memo1->Lines->Add("Listening...");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
IdIPMCastClient1->Active = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{ if(OpenDialog1->Execute())
{
IdIPMCastServer1->Active = true;
TMemoryStream *ms=new TMemoryStream;
ms->LoadFromFile(OpenDialog1->FileName);
Memo1->Lines->Add(OpenDialog1->FileName " send");
AnsiString sz;
sz.SetLength(ms->Size);
CopyMemory(&sz[1], ms->Memory, ms->Size); //multicasting file
IdIPMCastServer1->Send(sz);
Memo1->Lines->Add("file multicasting...");
IdIPMCastServer1->Active = false;
Memo1->Lines->Add("multicast fin...");
delete ms;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdIPMCastClient1IPMCastRead(TObject *Sender,
TStream *AData, TIdSocketHandle *ABinding)
{
Memo1->Lines->Add("receiving..."); TMemoryStream *ms=new TMemoryStream;
ms->CopyFrom(AData, AData->Size);
ms->SaveToFile("c:\\multicast.jpg");
delete ms; Memo1->Lines->Add("received"); }
//---------------------------------------------------------------------------
|
流
中階會員 發表:36 回覆:142 積分:70 註冊:2003-07-24 發送簡訊給我 |
Kboy 您好: (1)
試試在 ms->LoadFromFile(OpenDialog1->FileName) ; 之後加上
ms->Position = 0 ; (2)
將 CopyMemory(&sz[1], ms->Memory, ms->Size) ; 改成
CopyMemory(&sz[0], ms->Memory, ms->Size); Win32 SDK 說明: The CopyMemory function copies a block of memory from one location to another. VOID CopyMemory
(
PVOID Destination, // address of copy destination
CONST VOID *Source, // address of block to copy
DWORD Length // size, in bytes, of block to copy
) ;
Parameters Destination
Points to the starting address of the copied block's destination. Source
Points to the starting address of the block of memory to copy. Length
Specifies the size, in bytes, of the block of memory to copy.
|
Kboy
一般會員 發表:1 回覆:3 積分:0 註冊:2003-08-01 發送簡訊給我 |
多謝流大大的回答...
但是我用此方法試的時候會產生
Project Project1.exe raised exception class ERangeError with message".Process stopped. Use Step or Run to continue.
若繼續執行程式的話會當掉... 根據我自己的觀察,看網路的情形,似乎資料有送出去...
但好像都無法觸發IdIPMCastClient1的OnIPMCastRead這個event... 發表人 - Kboy 於 2004/02/23 18:06:46
|
流
中階會員 發表:36 回覆:142 積分:70 註冊:2003-07-24 發送簡訊給我 |
|
Kboy
一般會員 發表:1 回覆:3 積分:0 註冊:2003-08-01 發送簡訊給我 |
|
流
中階會員 發表:36 回覆:142 積分:70 註冊:2003-07-24 發送簡訊給我 |
|
Kboy
一般會員 發表:1 回覆:3 積分:0 註冊:2003-08-01 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |