C++ Socket Help
Basically, I tried making a small IRC client.
I'm stuck on Sockets (Oh boy)
Can someone explain in some detail how to use sockets/what they are?
I couldn't find a good tutorial online about what they are and how to use them properly(With examples)
This is what I got, error is on the connect line:
I'm stuck on Sockets (Oh boy)
Can someone explain in some detail how to use sockets/what they are?
I couldn't find a good tutorial online about what they are and how to use them properly(With examples)
This is what I got, error is on the connect line:
Code:
#include <winsock2.h>
#include <iostream>
using namespace std;
int main(){
const int iReqWinsockVer = 2;
WSADATA wsaData;
if (WSAStartup(MAKEWORD(iReqWinsockVer,0), &wsaData)==0)
{
if (LOBYTE(wsaData.wVersion) >= iReqWinsockVer)
{
struct sockaddr{
u_short sa_family;
char sa_date[14];
};
struct sockaddr_in
{
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
}sockAddr;
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = htons(80);
sockAddr.sin_addr.S_un.S_addr = inet_addr("192.168.1.114");
SOCKET s;
s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(s != INVALID_SOCKET)
if(connect(s, (&sockAddr), sizeof(sockAddr))!=0)
{
cout << "Failed";
}
}
else
{
}
if (WSACleanup()!=0)
{
// cleanup failed
}
}
else
{
// startup failed
}
}