Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / APG / Sockets / Basic.cpp
blobbb5fe12b7bb5920c4c46202a188710cda2a209bb
1 #include "ace/INET_Addr.h"
2 #include "ace/SOCK_Stream.h"
3 #include "ace/SOCK_Connector.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/OS_NS_unistd.h"
7 int ACE_TMAIN (int, ACE_TCHAR *[])
9 // Listing 1 code/ch06
10 ACE_INET_Addr srvr (50000, ACE_LOCALHOST);
11 // Listing 1
13 // Listing 2 code/ch06
14 ACE_SOCK_Connector connector;
15 ACE_SOCK_Stream peer;
17 if (-1 == connector.connect (peer, srvr))
18 ACE_ERROR_RETURN ((LM_ERROR,
19 ACE_TEXT ("%p\n"),
20 ACE_TEXT ("connect")), 1);
21 // Listing 2
23 ssize_t bc;
24 char buf[64];
26 // Listing 3 code/ch06
27 peer.send_n ("uptime\n", 7);
28 bc = peer.recv (buf, sizeof(buf));
29 ACE_OS::write (ACE_STDOUT, buf, bc);
30 peer.close ();
31 // Listing 3
33 return (0);