OpenSSL VPN Serveurs de messagerie |
OpenSSL/ClientTCPclient TCP // client.cpp : application console // #include "stdafx.h" // insérer Ws2_32.lib dans Link>General>Library Modules #define CHK_NULL(x) if ((x)==NULL) exit (1) #define CHK_ERR(err,s) if ((err)==-1) { perror(s); exit(1); } #define CHK_SSL(err) if ((err)==-1) { ERR_print_errors_fp(stderr); exit(2); } int main(int argc, char* argv[]) { WSADATA wsaData; SOCKET sd; struct sockaddr_in sa; hostent* remoteHost; int err; //----------------------------------------------- // Initialize Winsock WSAStartup(MAKEWORD(2,2), &wsaData); sd = socket(AF_INET, SOCK_STREAM, 0); CHK_ERR(sd, "socket"); memset (&sa, '\0', sizeof(sa)); sa.sin_family = AF_INET; //sa.sin_addr.s_addr = inet_addr ("172.31.198.15"); /* Server IP */ remoteHost = gethostbyname("sec030dev146"); sa.sin_addr.s_addr = *((u_long*)remoteHost->h_addr_list[0]); sa.sin_port = htons (400); /* Server Port number */ err = connect(sd, (struct sockaddr*) &sa,sizeof(sa)); CHK_ERR(err, "connect"); int bytesSent; char sendbuf[32] = "hello world"; bytesSent = send( sd, sendbuf, strlen(sendbuf), 0 ); closesocket(sd); cleanUp: WSACleanup(); return 0; } |