Hello
I have a problem with this code. I'm trying to connect to local dns server in order to get the ip of the hostname( that user would enter). For now, i'm just trying to connect to the local dns server, and this code gives me following 8 errors..
client.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
client.obj : error LNK2001: unresolved external symbol __imp__connect@12
client.obj : error LNK2001: unresolved external symbol __imp__htons@4
client.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
client.obj : error LNK2001: unresolved external symbol __imp__socket@12
client.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
client.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
Debug/client.exe : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.
The code goes here
#define WIN32_LEAN_AND_MEAN
#pragma comment(lib, "wininet.lib")
#include <winsock2.h>
#include <windows.h>
#include <iostream.h>
#include <conio.h>
#include <string>
using namespace std;
void main()
{
WSADATA wsadat;
WORD rVersion;
rVersion = MAKEWORD(2,0);
if(WSAStartup(rVersion, &wsadat) != NO_ERROR)
{
cout<<"WSA initialization failed.\n";
WSACleanup();
return;
}
SOCKET client;
client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(client == INVALID_SOCKET)
{
cout<<"Error creating socket.\n";
WSACleanup();
return;
}
char *ip= "208.67.222.222";
cout<<ip;
SOCKADDR_IN server;
server.sin_family= AF_INET;
server.sin_addr.s_addr= inet_addr(ip);
server.sin_port= htons(53);
if(connect(client, (SOCKADDR*) &server, sizeof(server)) == SOCKET_ERROR)
{
cout<<"Connection cannot be established. \n";
WSACleanup();
return;
}
closesocket(client);
WSACleanup();
return;
}
I don't know what to do... Kindly help me out, I need to submit my assignment by Friday......
Regards