| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 
 | #include <stdio.h>
#pragma hdrstop
 
 
 
#include "U_Connection.h"
 
#include <stdlib.h>
#include <string.h>
 
 
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
    var=1;
    int n;
 
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::BtConnectionClick(TObject *Sender)
{
  if(var==0)
  {
    Client->Active=false;
    BtConnection->Caption="Connexion";
 
    var=1;
  }
  else if(var==1){
    Client->Address=(EdtAdresse->Text); // insertion de l'adresse IP saisie dans le composant socket
    Client->Port=StrToInt(EdtPort->Text); // insertion du port saisie dans le composant socket
 
    Client->Active=true;
    BtConnection->Caption="Deconnexion";
 
    var=0;
  }
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::ClientRead(TObject *Sender,
      TCustomWinSocket *Socket)
{
   AnsiString recept=Socket->ReceiveText();
 
}
//---------------------------------------------------------------------------
 
void __fastcall TForm1::BtenvoiCdeClick(TObject *Sender)
{
 
    sCommande="GET /cgi-bin/camctrl.cgi?move=right HTTP/1.1";
    sCommande+="Host: 192.168.2.5";
    sCommande+="User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;rv:1.9.0.17) Gecko/2009122116 Firefox/3.0.17";
    sCommande+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    sCommande+="Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
    sCommande+="Accept-Encoding: gzip,deflate";
    sCommande+="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    sCommande+="Keep-Alive: 300";
    sCommande+="Connection: keep-alive";
 
    sCommande+="\r"; // \r veut dire que la commande est finie
 
    strcpy(cCommande,sCommande.c_str()); // cCommande (tableau) prend la valleur de sCommande qui a été transformé en chaine AZERTY par la fonction .c_str()
 
    send((unsigned int)Client, cCommande, strlen(cCommande), 0); //envoi de la commande
 
 
} | 
Partager