Skip to content

Instantly share code, notes, and snippets.

@yifu
Created September 21, 2012 15:06
Show Gist options
  • Select an option

  • Save yifu/3762046 to your computer and use it in GitHub Desktop.

Select an option

Save yifu/3762046 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <ace/Event_Handler.h>
#include <ace/Connector.h>
class MySvcHandler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
{
};
class Session : public ACE_Event_Handler
{
public:
virtual ACE_HANDLE get_handle (void) const;
virtual int handle_output (ACE_HANDLE);
private:
ACE_HANDLE handle_;
};
int main()
{
std::cout << "hello world. ace client." << std::endl;
typedef ACE_Connector<My_Svc_Handler,ACE_SOCK_CONNECTOR> MyConnector;
ACE_INET_Addr addr("30001","127.0.0.1");
std::auto_ptr<My_Svc_Handler> const handler = new My_Svc_Handler;
ACE_Connector connector;
if(connector.connect(handler,addr) == -1)
ACE_ERROR(LM_ERROR,?%P|%t, %p?,?Connection failed?);
while(1)
ACE_Reactor::instance()->handle_events();
}
ACE_HANDLE Session::get_handle (void) const
{
return handle_;
}
int Session::handle_output (ACE_HANDLE)
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment