Well, i think it's working:
--------------------------------------------------------------------
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>sock
4325424
C:\>
--------------------------------------------------------------------
The source code, can you tell me if the
if (WSAStartup(MAKEWORD(1,1), &info) != 0)
and the else are correct?
Source code:
Code:
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
int IRCconnect()
{
int sockfd;
struct sockaddr_in dest_addr;
WSADATA info;
if (WSAStartup(MAKEWORD(1,1), &info) != 0) {
MessageBox(NULL, "Cannot initialize WinSock!", "WSAStartup", MB_OK);
return(1);
}
else
{
MessageBox(NULL, "Winsock started!", "OK", MB_OK);
}
sockfd = socket(AF_INET,SOCK_STREAM,0);
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = htons(6667);
dest_addr.sin_addr.s_addr = inet_addr("80.105.107.170");
if (connect(sockfd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) >= 0)
printf("\n%d", "Connected succesfully");
else
{
//MessageBox(NULL, "Cannot initialize WinSock!", "ERROR 219", MB_OK);
printf("\n%d", "Connected...");
}
}
int main()
{
IRCconnect();
}