H
haoyunp
Unregistered / Unconfirmed
GUEST, unregistred user!
一个很简单的小程序,为什么在别的机器上都能受到信息,就一台收不到,网上邻居能
访问到该机器。
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int I;
AnsiString C;
TMemoryStream * MyStream =new TMemoryStream();
C=Edit1->Text;
I=C.Length();
MyStream->Write(&C[1],I);
NMUDP1->LocalPort=10061;
NMUDP1->RemotePort=10061;
NMUDP1->ReportLevel=Status_Basic;
NMUDP1->RemoteHost=Edit2->Text;//"192.168.0.255";// "zmn";;
NMUDP1->SendStream(MyStream);
delete MyStream;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMUDP1DataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP, int Port)
{
char *TmpBuffer=new char [NumberBytes+1];
AnsiString cs1;
int i;
TMemoryStream * MyStream =new TMemoryStream();
AnsiString C;
int I;
NMUDP1->ReadBuffer(TmpBuffer,NumberBytes,i);
TmpBuffer[NumberBytes]='/0';
RichEdit1->Text=RichEdit1->Text+"Bytes:"+NumberBytes+TmpBuffer;
Edit3->Text=TmpBuffer;
cs1=AnsiString(TmpBuffer);
//-----------关闭
if (cs1=="gb" {Close();}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
NMUDP1->LocalPort=StrToInt(Edit4->Text);
NMUDP1->RemotePort=StrToInt(Edit5->Text);
NMUDP1->ReportLevel=Status_Basic;
}
//---------------------------------------------------------------------------
访问到该机器。
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int I;
AnsiString C;
TMemoryStream * MyStream =new TMemoryStream();
C=Edit1->Text;
I=C.Length();
MyStream->Write(&C[1],I);
NMUDP1->LocalPort=10061;
NMUDP1->RemotePort=10061;
NMUDP1->ReportLevel=Status_Basic;
NMUDP1->RemoteHost=Edit2->Text;//"192.168.0.255";// "zmn";;
NMUDP1->SendStream(MyStream);
delete MyStream;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::NMUDP1DataReceived(TComponent *Sender,
int NumberBytes, AnsiString FromIP, int Port)
{
char *TmpBuffer=new char [NumberBytes+1];
AnsiString cs1;
int i;
TMemoryStream * MyStream =new TMemoryStream();
AnsiString C;
int I;
NMUDP1->ReadBuffer(TmpBuffer,NumberBytes,i);
TmpBuffer[NumberBytes]='/0';
RichEdit1->Text=RichEdit1->Text+"Bytes:"+NumberBytes+TmpBuffer;
Edit3->Text=TmpBuffer;
cs1=AnsiString(TmpBuffer);
//-----------关闭
if (cs1=="gb" {Close();}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
NMUDP1->LocalPort=StrToInt(Edit4->Text);
NMUDP1->RemotePort=StrToInt(Edit5->Text);
NMUDP1->ReportLevel=Status_Basic;
}
//---------------------------------------------------------------------------