Blame view

src/connector.cpp 399 Bytes
48b4c725   Peter M. Groen   Setting up Socket-pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include "sockpp/connector.h"
  
  namespace sockpp {
  
  bool connector::connect(const sock_address& addr)
  {
      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;
  }
  
  }