?login_element?

Subversion Repositories NedoOS

Rev

Rev 8 | Blame | Compare with Previous | Last modification | View Log | Download

  1. // ╧ръхЄ ЇєэъЎшщ юсьхэр фрээ√ьш яю UDP
  2.  
  3. //---------------------------------------------------------------------------
  4. #include <vcl.h>
  5. #include <stdio.h>
  6. #include <NMUDP.hpp>
  7.  
  8. //---------------------------------------------------------------------------
  9. extern unsigned char BufEth[2000];
  10. extern int kolEth;
  11. int proshUDP;
  12.  
  13. //---------------------------------------------------------------------------
  14. class TMyUDP:public TObject
  15. {
  16. __published:
  17.         TNMUDP *NMUDP1;
  18.         TNMUDP *NMUDP2;
  19.         void __fastcall NMUDP1DataSend(TObject *Sender);
  20.         void __fastcall NMUDP2DataReceived(TComponent *Sender,
  21.           int NumberBytes, AnsiString FromIP, int Port);
  22. public:         // User declarations
  23.     __fastcall TMyUDP();
  24. };
  25.  
  26. //---------------------------------------------------------------------------
  27. //╩юэёЄЁєъЄюЁ
  28. __fastcall TMyUDP::TMyUDP()
  29. {
  30.     NMUDP1=new TNMUDP(NULL);
  31.     NMUDP2=new TNMUDP(NULL);
  32.     NMUDP1->OnDataSend=NMUDP1DataSend;
  33.     NMUDP2->OnDataReceived=NMUDP2DataReceived;
  34. }
  35.  
  36. //---------------------------------------------------------------------------
  37. TMyUDP *MyUDP;
  38. //---------------------------------------------------------------------------
  39. //╤ючфрЄ№ юс·хъЄ
  40. void ObUDP()
  41. {
  42.   proshUDP=1;
  43.   MyUDP=new TMyUDP();     // ёючфрЄ№ юс·хъЄ
  44. }
  45.  
  46. //---------------------------------------------------------------------------
  47. //╧хЁхфрЄ№ фрээ√х (UDP ёюъхЄ)
  48. void PeredUDP(AnsiString adr,int nport)
  49. //   adr   - рфЁхё ёхЄш Ethernet фы  ┴╙
  50. //   nport - эюьхЁ яюЁЄр
  51. {
  52.   MyUDP->NMUDP1->RemoteHost = adr;
  53.   MyUDP->NMUDP1->ReportLevel = Status_Basic;
  54.   MyUDP->NMUDP1->RemotePort = nport;
  55.   MyUDP->NMUDP1->SendBuffer(BufEth,kolEth,kolEth);   // яхЁхфрЄ№ срщЄ√
  56. }
  57.  
  58. //---------------------------------------------------------------------------
  59. // ─рээ√х яюыєўхэ√ (UDP ёюъхЄ)
  60. void __fastcall TMyUDP::NMUDP2DataReceived(TComponent *Sender,
  61.       int NumberBytes, AnsiString FromIP, int Port)
  62. {
  63.   if (NumberBytes<2000)
  64.     {
  65.     int j;
  66.     NMUDP2->ReadBuffer(BufEth, kolEth, j); //яЁюўшЄрЄ№ срщЄ√
  67.     proshUDP=0;
  68.     }
  69.   else
  70.     proshUDP=1;
  71. }
  72.  
  73. //---------------------------------------------------------------------------
  74. // ─рээ√х яхЁхфрэ√ (UDP ёюъхЄ)
  75. void __fastcall TMyUDP::NMUDP1DataSend(TObject *Sender)
  76. {
  77.     proshUDP=0;
  78. }
  79.  
  80. //---------------------------------------------------------------------------
  81. //╙фрышЄ№ юс·хъЄ
  82. void DelUDP()
  83. {
  84.    delete MyUDP;
  85. }
  86. //---------------------------------------------------------------------------
  87.  
  88.