1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <windows.h>
#include <winsock2.h>
#include <cstdlib>
#include <iostream>
using namespace std;
WSADATA wsaData;
WORD version;
int error;
version = MAKEWORD(2,0);
error = WSAStartup(version, &wsadata);
if (error !=0)
{
return FALSE;
}
if (LOBYTE(wsaData.wVersion) !=2 ||
HIBYTE(wsaData.wVersion) !=0)
{
WSACleanup();
return FALSE;
}
SOCKET server
server = socket(AF_INET, SOCK_STREAM, O);
struct sockaddr_in sin;
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET
sin.sin_addr.s-adr = INADDR_ANY;
sin.sin_port = htons(21);
if (bind(server, &sin, sizeof sin) == SOCKET_ERROR)
return FALSE;
while (listen(server, SOMAXCONN) == SOCKKET_ERROR);
SOCKET client;
int length;
length = sizeof sin;
client = accept(server, &sin, &length);
SOCKET client
client = socket(AF_INET, SOCK_STREAM, 0);
struct hostent host;
host = gethostbyname("nigger.ca");
struct sockaddr_in sin;
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = ((struct in_addr *)(host->h_addr))->s_addr;
sin.sin_point = htons(21);
if (connect(client, &sin, sizeof sin) == SOCKET_ERROR)
{
return FALSE;
}
closesocket(server);
WSACleanup();
|