Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Сети > Помогите найти ошибку (IdUDPServer)


Автор: D7_beginner 28.12.2007, 16:09
Уважаемые форумчане помогите найти ошибку плиз!  smile  smile 

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, sTooledit, StdCtrls, Mask, sMaskEdit, sCustomComboEdit, sCurrEdit,
sComboBoxes, sButton, sHintManager, sSkinProvider, sSkinManager,
ExtCtrls, sSplitter, sPanel, sMemo, ComCtrls, ToolWin, sToolBar, sStatusBar,
sComboBox, sFontCtrls, sLabel, ExtActns, ActnList, StdActns, XPStyleActnCtrls,
ActnMan, RzCmboBx, TntStdCtrls, TntComCtrls, RzStatus, RzDBStat, RzPanel,
IdUDPClient, IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer,
IdServerIOHandler, IdServerIOHandlerSocket,
IdIOHandlerSocket, IdIOHandler, IdIOHandlerStream, IdTCPConnection,
IdTCPClient, acMagn, Menus, IdSocketHandle;

type
TForm1 = class(TForm)
sSkinManager1: TsSkinManager;
sHintManager1: TsHintManager;
sSplitter1: TsSplitter;
TntMemo1: TTntMemo;
TntMemo2: TTntMemo;
sToolBar2: TsToolBar;
RzFontComboBox1: TRzFontComboBox;
ToolButton3: TToolButton;
TntComboBox1: TTntComboBox;
ToolButton4: TToolButton;
RzStatusBar1: TRzStatusBar;
RzClockStatus1: TRzClockStatus;
Panel1: TPanel;
TntButton1: TTntButton;
RzPanel1: TRzPanel;
sSplitter2: TsSplitter;
sSplitter3: TsSplitter;
sSplitter4: TsSplitter;
sSplitter5: TsSplitter;
IdUDPClient1: TIdUDPClient;
IdUDPServer1: TIdUDPServer;
procedure IdUDPServer1UDPRead(Sender: TObject; AData: TBytes;
ABinding: TIdSocketHandle);
procedure TntButton1Click(Sender: TObject);
procedure TntComboBox1Change(Sender: TObject);
procedure RzFontComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TBytes;
ABinding: TIdSocketHandle);
var sfs:TStringStream; s:string;
begin
sfs:=TStringStream.Create('');
sfs.CopyFrom(AData,AData.Size);
TntMemo1.Lines.Add(ABinding.PeerIP+' '+sfs.DataString);
ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort s[1], Length(s));
sfs.Free
end;


procedure TForm1.RzFontComboBox1Change(Sender: TObject);
begin
TntMemo2.Font.Name:=RzFontComboBox1.SelectedFont.N ame;
end;

procedure TForm1.TntButton1Click(Sender: TObject);
begin
IdUDPClient1.Send(TntMemo2.Text);
end;

procedure TForm1.TntComboBox1Change(Sender: TObject);
begin
TntMemo2.Font.Size:=StrToInt(TntComboBox1.Text);
end;


Текст ошибки: 

[Pascal Error] Unit1.pas(40): E2003 Undeclared identifier: 'TBytes'
[Pascal Error] Unit1.pas(63): E2029 ')' expected but identifier 'Size' found
[Pascal Error] Unit1.pas(64): E2066 Missing operator or semicolon
[Pascal Error] Unit1.pas(65): E2010 Incompatible types: 'TBytes' and 'Char'
[Pascal Error] Unit1.pas(65): E2010 Incompatible types: 'TIdIPVersion' and 'Integer'
[Pascal Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'

Автор: MetalFan 28.12.2007, 16:22
ошибка в ДНК.  smile 

Автор: SneG0K 28.12.2007, 17:02
Модератор: Сообщение скрыто.

Автор: Ch0bits 28.12.2007, 17:02
Приведённый пример рассчитан на более старую версию Indy + куча очепяток.

А так ошибка в ДНК.  smile 

Автор: SneG0K 28.12.2007, 17:05
Цитата(D7_beginner @  28.12.2007,  15:09 Найти цитируемый пост)
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, sTooledit, StdCtrls, Mask, sMaskEdit, sCustomComboEdit, sCurrEdit,
sComboBoxes, sButton, sHintManager, sSkinProvider, sSkinManager,
ExtCtrls, sSplitter, sPanel, sMemo, ComCtrls, ToolWin, sToolBar, sStatusBar,
sComboBox, sFontCtrls, sLabel, ExtActns, ActnList, StdActns, XPStyleActnCtrls,
ActnMan, RzCmboBx, TntStdCtrls, TntComCtrls, RzStatus, RzDBStat, RzPanel,
IdUDPClient, IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer,
IdServerIOHandler, IdServerIOHandlerSocket,
IdIOHandlerSocket, IdIOHandler, IdIOHandlerStream, IdTCPConnection,
IdTCPClient, acMagn, Menus, IdSocketHandle;



Нахрена тебе столько в uses??? если ты с элементарными ошибками справится не можеш!!!

Автор: Sanchezzz 28.12.2007, 20:25
Цитата

Нахрена тебе столько в uses??? если ты с элементарными ошибками справится не можешь!!!

какая разница сколь ко ты в uses написал...
---
решение
чтоб он знал про TBytes; пропиши в uses IdGlobal
яб читал Tbytes так
Код

procedure TForm1.ServerUDPRead(Sender: TObject; AData: TBytes;
  ABinding: TIdSocketHandle);
begin
memo1.Lines.Add(Bytestostring(AData));
end;



Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)