Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by 12312312 ( 15 years ago )
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define _WINSOCKAPI_
#include <windows.h>
#include <winsock2.h>
/*Далее заходим в Project Properties - Linker - Input - Additional Dependencies и вводим в эту строку WS2_32.lib*/
SOCKET MainSocket;
DWORD ID;
int main()
{
char addr[]="192.168.0.64:3030"; //ykazivaem klientskii adres (127.0.0.1)
WORD version=MAKEWORD(2,0);
WSADATA wsa;
WSAStartup(version, &wsa;);
sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_addr.s_addr=inet_addr(addr); // ukazivaem tot adres, k kakomy podsoedin9ems9
sa.sin_port=htonl(27015); //27015 - nomer porta;
if ( connect( MainSocket, (SOCKADDR*)&sa;, sizeof(sa) ) ) /*ystanavlivaem soedinenie s serverom. connect vozvrawaet 0 v slu4ae uda4nogo soedineni9*/
{
printf ("Connection failed");
getch();
return 0;
}
printf ("Connection established");
for (;;)
{
int v=send(MainSocket, "abcd",5,0);
if (!v || v==SOCKET_ERROR)
{
printf ("Connection failed");
getch();
return 0;
}
}
}
Revise this Paste
Parent: 28897