# Unresolved external symbol using Winsock2 Functions

This topic is 1735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey there,

I'm trying to create a simple UDP socket, and send packets between the server and clients, although I'm getting a very strange error, I can't seem to figure out how to fix it, would really appreciate any help.

This is code for my client, creating the socket

void Application::Init_Winsock()
{
WSAStartup(MAKEWORD(2,2), &Winsock);

if(LOBYTE(Winsock.wVersion) !=2 || HIBYTE(Winsock.wVersion) !=2)	//Check version
{
WSACleanup();	//Cleanup and return false if version is wrong
return;
}

//Create Socket
Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

RemoteAddress.sin_family = AF_INET;								//Set the Address Family
RemoteAddress.sin_port = SERVER_PORT;							//Set Port
}

void Application::Send_Packet(PLAYER* data)
{
}


And these are the errors:

And then I'm getting a very similar problem with my Server application as well, here is the code for the server, I've also declared RecvThread as a static:

		static DWORD WINAPI RecvThread(LPVOID);


void Application::Init_Winsock()
{
WSAStartup(MAKEWORD(2,2), &Winsock);

if(LOBYTE(Winsock.wVersion) !=2 || HIBYTE(Winsock.wVersion) !=2)	//Check Version
{
WSACleanup();	//Cleanup and end if not version 2
return;
}

//Create Socket
Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

//Input Reciever Information
RemoteAddress.sin_family = AF_INET;						//Set the Family Address
RemoteAddress.sin_port = SERVER_PORT;					//Set Port

//Start the recieve thread

}

DWORD WINAPI Application::RecvThread(LPVOID knock)
{
/*
while(true)
{
PLAYER Recv;

Player = Recv;
}
*/

Application *instance = static_cast<Application *>(knock);
while(true)
{
PLAYER Recv;

instance->Player = Recv;
}
}


and again, very similar error:

I'm stumped :S

Edited by Xooch

##### Share on other sites

This is documented as needed on MSDN. If you scroll back to the end of the page for WSAStartup, it should list the header and link library you need.

##### Share on other sites

Yo,

Thanks for the reply, I did as you said but still nothing has changed. Although I did include both folders, as I didn't know which one to include, could this cause a problem?

-

##### Share on other sites

But did you add the libraries to the project as he asked for? That option is the "Additional Dependecies" in the "Linker->Input" section of the project options. What you showed is just the paths the linker will look at for the library files you add.

edit: And by the way, the paths you added looks like the standard path for the Windows API that should be automatically added if you have installed it. You should not add them again then.

Edited by Brother Bob

##### Share on other sites

Yep, working now, thanks man