Recent Changes - Search:

Accueil

OpenSSL

SyncML

Apache Portable Runtime

Libxml2

Net-snmp

CUrl

Boost

Perl

ZLib

Samba

VPN

Serveurs de messagerie

edit

OpenSSL/ClientTCP

client 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;
}
 
Edit - History - Print - Recent Changes - Search
Page last modified on January 09, 2006, at 11:54 PM