I have been trying to learn network programming so I wrote a simple program which checks whether a socket has been created or not. I am running it in Vs Code latest version but it gives
C:\Users\KIIT\AppData\Local\Temp\ccu4j9bq.o:server.cpp:(.text+0x20): undefined reference to `__imp_socket' collect2.exe: error: ld returned 1 exit status
I did check the internet, it says to link ws2_32.dll file but I cannot find an option to do so.
What should i do?
#include <winsock2.h>
#include <ws2tcpip.h>
#include<iostream>
#pragma comment(lib, "Ws2_32.lib")
using namespace std;
int main()
{
int sc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sc)
cout << "created";
else
cout << "not created";
return 0;
}