I've been working with the same code with my school for weeks now. I don't know what I do that fixes thee issues, all I know is that whenever I add code, they come right back. I've read everything off MSDN, I've read almost everything here about linkers and setting things up, I still do not know. Please help me. I understand the issue is with the linker not connecting the header file to the library?
int TCPEchoed(SOCKET fd){
char buf[BUFSIZE];
int clientData;
clientData = recv(fd, buf, sizeof buf, 0);
while (clientData != SOCKET_ERROR && clientData > 0)
{
buf[clientData] = '\0';
fprintf(stderr, buf);
clientData = recv(fd, buf, sizeof buf, 0);
}
if (clientData == SOCKET_ERROR)
{
fprintf(stderr, "echo recv error: %d\n", GetLastError());
}
closesocket(fd);
return 0;
}
This is the latest function that brings about the terrible error. "error LNK2019: unresolved external symbol "int __cdecl TCPechoed(unsigned int)" (?TCPechoed@@YAHI@Z) referenced in function "void __cdecl TCPecho(char const *,char const *)" (?TCPecho@@YAXPBD0@Z)"
I move stuff around and I am able to find out that the error is caused by this line.
_beginthread((void (*)(void *))TCPechoed, STKSIZE, (void *)s);
When I toss it into the main function, I get the error occurs in the main function. I have the function declared at the top as:
int TCPechoed(SOCKET fd);
I would love if someone could assist me on this problem, and teach me what it is that is going wrong so I never have to post about this again.
Thanks.