Blame view

src/connector.cpp 430 Bytes
ea9eaf95   Peter M. Groen   Fixed Headers
1
  #include "socket-cpp/connector.h"
48b4c725   Peter M. Groen   Setting up Socket-pp
2
  
ea9eaf95   Peter M. Groen   Fixed Headers
3
  using namespace osdev::components::socket-cpp;
48b4c725   Peter M. Groen   Setting up Socket-pp
4
  
ea9eaf95   Peter M. Groen   Fixed Headers
5
  bool connector::connect( const sock_address& addr )
48b4c725   Peter M. Groen   Setting up Socket-pp
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  {
      sa_family_t domain = addr.family();
  	socket_t h = create_handle(domain);
  
  	if (!check_ret_bool(h))
  		return false;
  
  	// This will close the old connection, if any.
  	reset(h);
  
  	if (!check_ret_bool(::connect(h, addr.sockaddr_ptr(), addr.size())))
  		return close_on_err();
  
  	return true;
  }