I've got error during compilation. MSVS don't see any problems. But compiller.. Help me, pls.
Errors:
Error LNK1120 unresolved external elements 7 CryptoCAT C: \ Users \ alexx \ onedrive \ documents \ visual studio 2015 \ Projects \ CryptoCAT \ Debug \ CryptoCAT.exe 1
Error LNK2019 unresolved external reference to the symbol __imp__connect @ 12 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
Error LNK2019 unresolved external reference to the symbol __imp__htons @ 4 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
Error LNK2019 unresolved external reference to the symbol __imp__inet_addr @ 4 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
Error LNK2019 unresolved external reference to the symbol __imp__recv @ 16 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
Error LNK2019 unresolved external reference to the symbol __imp__send @ 16 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
Error LNK2019 unresolved external reference to the symbol __imp__socket @ 12 as a function of "char * __cdecl heh (char *, char *)" (heh @@ YAPADPAD0 @ Z?)
#include "stdafx.h"
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
char * heh(char *ip, char *msg) {
int sock;
struct sockaddr_in server;
char server_reply[2000];
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1)
{
return "nosocket";
}
server.sin_addr.s_addr = inet_addr(ip);
server.sin_family = AF_INET;
server.sin_port = htons(4567);
if (connect(sock, (struct sockaddr *)&server, sizeof(server)) < 0)
{
return "connectfail";
}
if (send(sock, msg, strlen(msg), 0) < 0)
{
return "sendfail";
}
if (recv(sock, server_reply, 2000, 0) < 0)
{
return "recv failed";
}
return server_reply;
closesocket(sock);
}