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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#define WIN32_LEAN_AND_MEAN
#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <Winsock2.h>
#include <WS2tcpip.h>
#include <windows.h>
#pragma comment (lib,"ws2_32")
int _tmain(int argc, _TCHAR* argv[])
{
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2),&wsaData);
SOCKET m_socket;
m_socket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(m_socket==INVALID_SOCKET)
{
printf("Invalid Socket :WSAGetLastError()");
}
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr("127.0.0.1");
clientService.sin_port = htons(5209);
LPHOSTENT host = gethostbyname("72.144.89.32");
if(connect(m_socket,(SOCKADDR*)&clientService,sizeof(clientService))==SOCKET_ERROR)
{
printf("Connection Failure");
WSACleanup();
return 1;
}
char buffer[2048];
strcpy(buffer,"POST /dbarea.php HTTP/1.1\n");
strcat(buffer,"Content - Type:application/x-www-form-urlencoded\n");
strcat(buffer,"Host: localost\n");
strcat(buffer,"content-Length:32\n");
strcat(buffer,"\n");
strcat(buffer,"username=emeka1&password=laikan112");
//int n = write(SOCKADDR*,buffer,strlen(buffer));
printf("Data Sent Successfully..");
return 0;
}
|