Home > Back-end >  Consult NMUDP control is applied to implement the sending and receiving data. Thanks!
Consult NMUDP control is applied to implement the sending and receiving data. Thanks!

Time:09-24

Header file SRData. H as follows:
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# # ifndef SRDataH
# define SRDataH
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# include & lt; Classes. Hpp>
# include & lt; Controls. Hpp>
# include & lt; StdCtrls. Hpp>
# include & lt; Forms. Hpp>
# include & lt; ComCtrls. Hpp>
# include & lt; NMUDP. Hpp>
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The class TForm1: public TForm
{
__published://IDE - managed Components
Label1 TLabel *;
TLabel * Label2;
TLabel * Label3;
TLabel * Label4;
TEdit Edit1 *;
For the TButton *;
TButton * Button2;
TMemo * Memo1;
TStatusBar * StatusBar1;
TNMUDP * NMUDP1;
Edit2 TEdit *;
Edit3 TEdit *;
Void __fastcall Button1Click (TObject * Sender);
Void __fastcall Button2Click (TObject * Sender);
Void __fastcall Memo1Change (TObject * Sender);
Void __fastcall NMUDP1BufferInvalid (bool & amp; Handled,
_ARRAYOF Buff, char * const int Buff_Size, int & amp; Length);
Private://User declarations
Public://User declarations
__fastcall TForm1 (TComponent * Owner);
};
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Extern PACKAGE TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# endif

SRData. CPP file as follows:
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# include & lt; The VCL. H>
# pragma hdrstop

# include "SRData. H"
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
If (OpenDialog1 - & gt; The Execute ())
{
Edit3 - & gt; Text=OpenDialog1 - & gt; The Filename.
}
Memo1 - & gt; Text="";
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button2Click (TObject * Sender)
{
If (Edit3 - & gt; Text=="")
{
ShowMessage (" both Please select one file ");
return;
}
NMUDP1 - & gt; RemoteHost=Edit1 - & gt; The Text;//design to the remote host and port number
NMUDP1 - & gt; RemotePort=StrToInt (Edit2 - & gt; The Text);
NMUDP1 - & gt; ReportLevel=Nmudp: : Status_Basic;
Const int ThreshHold=2048;//every time I read 2048 bytes of data
TFileStream * Strm=new TFileStream (Edit3 - & gt; Text, fmOpenRead);//load the file stream
Char * Buffer=new char [ThreshHold];//store read data buffer
Int BuffSize=Strm - & gt; The Size;//file size
Int Buffers=BuffSize/ThreshHold;//loop reads
for(int i=0; I<=Buffers; I++)//read the file data
{
If (BuffSize> 2048)
{
Strm - & gt; Read (Buffer, ThreshHold);
NUMUDP1 - & gt; SendBuffer (Buffer, the ThreshHold, ThreshHold);
}
The else
{
Strm - & gt; Read (Buffer, BuffSize);
NMUDP1 - & gt; SendBuffer (Buffer, the ThreshHold, ThreshHold);

BuffSize=ThreshHold;
ShowMessage (" hehe ");
}
The delete [] Buffer;
Delete the Strm;
Memo1 - & gt; Lines - & gt; Add (" ");
//error problem is as follows:
[Error] c + + SRData. H (32) : E2303 Type name expected
[Error] c + + SRData. CPP (19) : E2451 Undefined symbol 'OpenDialog1'
[Error] c + + SRData. CPP (52) : E2206 Illegal character '} '(0 xa3fd)
/c + + Error SRData. CPP (64) : E2089 Identifier 'NMUDP1DataSend' always have a type, the qualifier
[Error] c + + SRData. CPP (71) : E2206 Illegal character '} '(0 xa3fd)
[Error] c + + SRData. CPP (77) : E2451 Undefined symbol 'TmpBuffer'
[Error] c + + SRData. CPP (77) : E2451 Undefined symbol 'NumberBytes'
[Error] c + + SRData. CPP (80) : E2252 'catch' expected

CodePudding user response:

Reply email: [email protected]
QQ: 85741820
Super thank you!

CodePudding user response:

OpenDialog1 form didn't put you? No OpenDialog1 __published section,

CodePudding user response:

No drag controls, not include the header file

CodePudding user response:

reference 1st floor rosana9 response:
reply email: [email protected]
QQ: 85741820
Super thank you!




refer to the second floor u010165006 response:
OpenDialog1 form didn't put you? No OpenDialog1 __published,

Thank you for your comment! Have to recompile, only one question:
/c + + Error SRDdata. CPP (65) : E2089 Identifier 'NMUDP1DataSend' always have a type, the qualifier.

65 lines of code is: before and after the void __fastcall TForm1: : NMUDP1DataSend (TObject * Sender)
{
StatusBar1 - & gt; Panels - & gt; The Items [0] - & gt; Text="File Completed? On "
}

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related