1 2 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
| #include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
SOCKET sock;
SOCKADDR_IN sin;
system("PAUSE");
sin.sin_addr.s_addr = inet_addr("http://serveur.4.free.fr");
sin.sin_family = AF_INET;
sin.sin_port = htons(80);
sock = socket(AF_INET,SOCK_STREAM,0);
printf("\n\n -> CONNEXION OK");
if(connect(sock,(SOCKADDR*)&sin,sizeof(sin))==0)
send(sock,"POST testation.php HTTP/1.1\r\n",500,0);
send(sock,"Host: http://serveur.4.free.fr\r\n",500,0);
send(sock,"Content-Type: application/x-www-form-urlencoded\r\n",49,0);
send(sock,"Content-Length: 28\r\n",20,0);
send(sock,"\r\n",2,0);
send(sock,"poste=poste1&texte=test\r\n",28,0);
send(sock,"\r\n",2,0);
closesocket(sock);
WSACleanup();
system("pause");
} |
Partager