全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3208
推到 Plurk!
推到 Facebook!

簡單的即時通要怎麼寫?

答題得分者是:harrypp
0083chu
一般會員


發表:6
回覆:7
積分:2
註冊:2009-08-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-08-27 16:37:47 IP:121.254.xxx.xxx 訂閱
我目前正好缺一項功能,就是一個簡單的即時通的功能,只要知道對方IP就可以傳字串過去,
並且顯示哪個IP送的。
可以的話懇求完整的架構&程式碼,以方便我整合。
拜託~~!! 拜託~~!!
------
CHU
harrypp
中階會員


發表:7
回覆:124
積分:61
註冊:2006-08-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-08-27 16:42:46 IP:218.210.xxx.xxx 訂閱
看完這篇再重新發問吧!!
http://delphi.ktop.com.tw/board.php?cid=32&fid=107&tid=66040
0083chu
一般會員


發表:6
回覆:7
積分:2
註冊:2009-08-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-08-27 21:12:24 IP:121.254.xxx.xxx 訂閱

===================引 用 harrypp 文 章===================
看完這篇再重新發問吧!!
http://delphi.ktop.com.tw/board.php?cid=32&fid=107&tid=66040

就是因為不知道才問,不是平白無故的就要別人付出。
我現在是要把一台執行的,分成2台來做,中間網路這段我沒做過,
關鍵字也查了但是找不到傳字串的方法。(有傳畫面的&傳檔的)
------
CHU
harrypp
中階會員


發表:7
回覆:124
積分:61
註冊:2006-08-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-08-28 01:28:48 IP:114.32.xxx.xxx 訂閱
起頭就要完整程式,會讓人感覺像幫你做作業。

建議你先搞懂Winsock,可以參考這篇
http://delphi.ktop.com.tw/board.php?cid=168&fid=920&tid=94676

傳字串不就是傳一個buffer過去,所以你得搞懂如何send,recv資料
0083chu
一般會員


發表:6
回覆:7
積分:2
註冊:2009-08-03

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-08-28 21:16:59 IP:121.254.xxx.xxx 訂閱
為什麼會出現這樣的訊息勒~~??
是哪裡出問題了嗎~~??

Error Reading Form
Class NMUDP1 not found. Ignore the error and contiune?
NOTE:Ignoring the error may cause components to be deleted or property values to be lost.
Ignore Cancel Ignore All

Error
Field Form1->NMUDP1 does not have a corresponding component. Remove the declaration?
Yes NO Cancel Help

[C Error] UDP_R1.h(10): E2209 Unable to open include file 'NMUDP.hpp'
[C Error] UDP_R1.h(16): E2303 Type name expected
[C Error] UDP_R1.h(16): E2139 Declaration missing ;
[C Error] UDP_R1.h(16): E2109 Not an allowed type
[C Error] UDP_R1.cpp(19): E2451 Undefined symbol 'NMUDP1'
[C Error] UDP_R1.cpp(27): E2451 Undefined symbol 'NMUDP1'

[code cpp]
.cpp
//---------------------------------------------------------------------------
#include
#pragma hdrstop

#include "UDP_R1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
NMUDP1->LocalPort=StrToInt(Edit1->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMUDP1DataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP, int Port)
{
char buffer[256];
int len;
NMUDP1->ReadBuffer(buffer,256,len);
buffer[len]=0;
Edit2->Text=StrPas(buffer);
Edit3->Text=FromIP;
StatusBar1->SimpleText=IntToStr(len) " bytes received!";
}
//---------------------------------------------------------------------------

[/code]

[code cpp]
.h
//---------------------------------------------------------------------------
#ifndef UDP_R1H
#define UDP_R1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp><br />#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TNMUDP *NMUDP1;
TLabel *Label1;
TEdit *Edit1;
TLabel *Label2;
TEdit *Edit2;
TLabel *Label3;
TEdit *Edit3;
TStatusBar *StatusBar1;
void __fastcall FormCreate(TObject *Sender);
void __fastcall NMUDP1DataReceived(TComponent *Sender, int NumberBytes,
AnsiString FromIP, int Port);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

[/code]

寫Socket(Client/Server)也是一樣的狀況...=.=
---------------------------------------------------------------------------------------------------------------------------------
我參考這裡的的資料做的
http://bit.kuas.edu.tw/~csshieh/teach/np/
------
CHU
編輯記錄
0083chu 重新編輯於 2009-08-28 21:21:14, 註解 無‧
系統時間:2024-06-21 13:44:13
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!