> From: owner-openssl-us...@openssl.org On Behalf Of Raj
> Sent: Thursday, 05 August, 2010 01:06

>     I will describe my code snippet below
> 
>     The module for connecting to server
> 
>          SOCKET RequestSock;
>          SOCKADDR_IN ClientAddr;
>          RequestSock = 
> WSASocket(AF_INET,SOCK_STREAM,0,NULL,0,WSA_FLAG_OVERLAPPED);

I don't know much about 'OVERLAPPED' in Windows, but I think 
it's something like 'nonblocking' in Unix.

>          pHost = gethostbyname(pcTargetURL);
>          memset(&ClientAddr,0,sizeof(ClientAddr));
>          int iAddrLen = sizeof(ClientAddr);
>          ClientAddr.sin_family = AF_INET;
>          memcpy(&ClientAddr.sin_addr,pHost->h_addr, pHost->h_length);
>          ClientAddr.sin_port = htons(atoi(pcPort));
>          if(0 != connect(RequestSock,(SOCKADDR *)&ClientAddr, 
> sizeof(SOCKADDR_IN)))
>          {
>               closesocket(RequestSock); // Connection failed
>               return false;
>          }
> 
>          WSAOVERLAPPED SendOverlapped;
>          DWORD dwSendDataLen = 0;
>          WSABUF ClientRequestBuf;
>          WSAEVENT SendEvent[1];
>          ClientRequestBuf.buf = pcData;
>          ClientRequestBuf.len = strlen(pcData);
>          SendEvent[0] = WSACreateEvent();
>          SendOverlapped.hEvent = SendEvent[0];
>          iRes = 
> WSASend(RequestSock,&ClientRequestBuf,1,&dwSendDataLen,dwFlag,
> &SendOverlapped,NULL);
>             // Sending data to the server
> 
At this point, the send probably hasn't actually happened.
And if you call [WSA]Recv and it returns, it almost certainly 
hasn't actually been done either. You probably have to do 
some kind of synchronization with the .hEvent, following 
whatever Windows rules are applicable. 

>     FYI
>         pcPort = 443
>         pcTargetURL = L"www.facebook.com";
>        pcData = "GET https://www.facebook.com HTTP/1.0\r\n\r\n"
> 


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to