everything is defined and such but its throwing me errors so here is my code
#include "stdafx.h" //don't touch this.
#include <winsock.h>
#include <string>
#include <iostream>
using namespace std;
int main()
{
//declaring some locals
string results = "";
int startupResult, connectResult, bytesSent, i = 0;
WSADATA wsaDATA;
SOCKET sock;
SOCKADDR_IN socketAddr;
char buffer[1024];
char *msg = "Hey there!";
//init WSA
startupResult = WSAStartup(MAKEWORD(2, 2), &wsaDATA);
if (startupResult != 0)
{
cout << "WSA Failed!!\n";
std::cin.get();
}
//setting sock params
sock = socket(AF_INET, SOCK_STREAM, 0);
socketAddr.sin_addr.s_addr = inet_addr("Some host here.");
socketAddr.sin_family = AF_INET;
socketAddr.sin_port = htons(3040);
//connecting the socket
connectResult = connect(sock, (SOCKADDR *) &socketAddr, sizeof(socketAddr));
if (connectResult != 0)
{
cout << "Socket Connection failed :(\n";
std::cin.get();
}
//sending the data
bytesSent = send(sock,msg,strlen(msg),0);
cout << "Bytes sent: " << bytesSent << endl;
//do while for um the data received...
do
{
i = recv(sock, buffer, sizeof(buffer), 0);
cout << "Received Data!" << endl;
results += buffer;
} while (i != 0);
cout << results;
return 0;
}
It's telling me that
_connect
_htons
_inet_addr
_recv
_send
_socket
_wsastartup
all referenced in _main but not defined? What could be the issue, I've been having a crack at it for an hour now with no results.