I'm getting the following errors:
Originally Posted by
Microsoft Visual C++ Express
1>------ Build started: Project: HTTP BOT, Configuration: Debug Win32 ------
1> httpBotBase.c
1>c:\users\stdioDOTh\desktop\http bot\http bot\bot.h(21): error C2061: syntax error : identifier 'wsaData'
1>c:\users\stdioDOTh\desktop\http bot\http bot\bot.h(21): error C2059: syntax error : ';'
1>c:\users\stdioDOTh\desktop\http bot\http bot\httpbotbase.c(13): error C2065: 'wsaData' : undeclared identifier
1>c:\users\stdioDOTh\desktop\http bot\http bot\httpbotbase.c(13): warning C4133: 'function' : incompatible types - from 'int *' to 'LPWSADATA'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Files:
bot.h
Code:
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <WinSock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "ws2_32.lib")
//Prototypes
void exitProcess(void);
int botConnect(void);
//Configuration these aren't used yet
#define PORT "80"
#define SERVERIP "127.0.0.1"
//
WSAData wsaData;
SOCKET Socket;
SOCKADDR_IN service;
LPHOSTENT host;
httpBotBase.c
Code:
#include "Bot.h"
int main(int argc, char *argv[])
{
atexit(exitProcess);
botConnect();
return 0;
}
int botConnect()
{
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0)
return 1;
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (Socket < 0)
return 1;
service.sin_family = AF_INET;
service.sin_port = htons(80); //Change this to PORT
host = gethostbyname("127.0.0.1");
if (!host) //Change this to SERVERIP
return 1;
printf("Successfully reached this point!");
}
void exitProcess()
{
puts("Program is now exiting.");
Sleep(2000);
getchar();
}