Jump to content

Socket->Server Connection


Recommended Posts

Guest My_Keul
Posted

Hi

I am going to write a small program in order to make a small client.

So i edited a small "typic hello world", and i just added in the "WndProc" fonction between "case IDOK" and "DestroyWindow(hwnd);" this code :

WSADATA WSAData;

WSAStartup(MAKEWORD(2,0), &WSAData);

SOCKET sock;

SOCKADDR_IN sin;

sock = socket(AF_INET, SOCK_STREAM, 0);

sin.sin_addr.s_addr = inet_addr("193.253.227.66");

sin.sin_family = AF_INET;

sin.sin_port = htons(7654);

connect(sock, (SOCKADDR *)&sin, sizeof(sin));

closesocket(sock);

WSACleanup();

The server is listenning on the 7654 port.

I did't forget this :

#include

#pragma comment(lib, "winsock.lib")

But this doesn't work : the server detect any connection of client..

Somebody can help me?

Thank

My_Keul

PS : sorry for my english level :)

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.