I've corrected a few things but it does not connect for some reason.
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
#pragma comment(lib,"ws2_32.lib")
int main(void)
{
WSADATA wData;
struct sockaddr_in addr;
SOCKET sock;
char buf[256];
int ret = 0;
if (WSAStartup(0x202, &wData) != 0)
{
puts("Error INitializing WSA");
return GetLastError();
}
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock == INVALID_SOCKET)
{
puts("Error Creating socket");
return (-1);
}
addr.sin_family = AF_INET;
addr.sin_port = htons(1234);
addr.sin_addr.s_addr = (unsigned long)inet_addr("192.168.1.17");
ret = connect(sock, (SOCKADDR *) &addr, sizeof(addr));
if (ret == -1)
{
puts("Error connecting");
return (-1);
}
send(sock, "Hello WOrld!", 15, 0);
recv(sock, buf, 256, 0);
closesocket(sock);
WSACleanup();
return (0);
}
John