Created
August 12, 2017 09:11
-
-
Save j2doll/ec3b190dcb7b186071fce437dab46e10 to your computer and use it in GitHub Desktop.
SimpleClient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SimpleClient.cpp | |
#include "ace/ACE.h" | |
#include "ace/INET_Addr.h" | |
#include "ace/SOCK_Connector.h" | |
#include "ace/SOCK_Stream.h" | |
int main() | |
{ | |
const char* pathname = "index.html"; | |
const char* server_name = "www.adobe.com"; | |
ACE_SOCK_Connector connector; | |
ACE_SOCK_Stream peer; | |
ACE_INET_Addr peer_addr; | |
// set address | |
peer_addr.set( 80, server_name ); | |
// connect | |
connector.connect( peer, peer_addr ); | |
char buf[1024]; | |
iovec iov[3]; | |
iov[0].iov_base = (void*) "GET"; | |
iov[0].iov_len = 4; // G E T null | |
iov[1].iov_base = (void*) pathname; | |
iov[1].iov_len = strlen(pathname); // + 1 ; | |
iov[2].iov_base = (void*) " HTTP/1.0\r\n\r\n"; | |
iov[2].iov_len = 13 ; | |
peer.sendv_n( iov, 3 ); | |
ssize_t n = 0; | |
// do { | |
n = peer.recv( buf, 1023 ); // receive buffer | |
buf[n] = 0; | |
ACE::write_n( ACE_STDOUT, buf, 1023 ); // print | |
// } while( n != 0 ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment