class::inet::SocketAddressInfo

class inet::SocketAddressInfo
  : public api::WorkObject

The Socket Address Info class is used to get socket address information for a given node and service.

For example, if you have a web URL this class can be used to converto that to information that can be used to open a socket.

The following is an example of how to use this class for connected to a server.

#include <sapi/inet.hpp>
#include <sapi/var.hpp>

SocketAddressInfo socket_address_info; //construct with defaults
Vector<SocketAddressInfo> result = socket_address_info.fetch_node("stratifylabs.co");

if( result.count() > 0 ){
 SocketAddress socket_address(result.at(0));
 Socket socket;
 socket.create(socket_address); //create a socket that can connect to stratifylabs.co

 socket.connect(socket_address); //connect to stratifylabs.co

 String request = "...";
 socket.write(request);
 //then read the response

 socket.close();
}

Summary

SocketAddressInfo(

int family,
int type,
int protocol,
int flags
)

const var::ConstString & canon_name() const

int family() const

var::Vector< SocketAddressInfo > fetch(

const arg::NodeToFetch node,
const arg::ServiceToFetch service
)

var::Vector< SocketAddressInfo > fetch_node(

const var::ConstString & node
)

var::Vector< SocketAddressInfo > fetch_service(

const var::ConstString & service
)

int flags() const

bool is_valid()

int protocol() const

void set_family(

int value
)

void set_flags(

int value
)

void set_protocol(

int value
)

void set_type(

int value
)

int type() const

enum family

enum protocol

enum type

Members

SocketAddressInfo(

int family,
int type,
int protocol,
int flags
)

Constructs a new socket address infomation object.

Parameters

  • family Socket family (defautl is FAMILY_INET)

  • type Socket type (default is TYPE_STREAM)

  • protocol Socket protocol (default is PROTOCOL_TCP)

  • flags Socket flags (default is none)


const var::ConstString & canon_name() const

int family() const

Accesses the family.


var::Vector< SocketAddressInfo > fetch(

const arg::NodeToFetch node,
const arg::ServiceToFetch service
)


var::Vector< SocketAddressInfo > fetch_node(

const var::ConstString & node
)

Fetches the socket address information from DNS servers based on the node and service specified.

#include <sapi/var.hpp>
#include <sapi/inet.hpp>

SocketAddressInfo address_info;
Vector<SocketAddressInfo> address_info.fetch_node("stratifylabs.co"); //get IP address and other info for stratifylabs.co

var::Vector< SocketAddressInfo > fetch_service(

const var::ConstString & service
)


int flags() const

Accesses the flags.


bool is_valid()

int protocol() const

Accesses the protocol.


void set_family(

int value
)

Sets the family for getting address info.


void set_flags(

int value
)

Sets the flags used for getting address info.


void set_protocol(

int value
)

Sets the protocol for getting address info.


void set_type(

int value
)

Sets the type for getting address info.


int type() const

Accesses the type.


enum family
  • FAMILY_NONE
  • FAMILY_INET IPV4
  • FAMILY_INET6 IPV6

Enumerates the socket address family options.


enum protocol
  • PROTOCOL_RAW Raw protocol
  • PROTOCOL_TCP TCP Protocol
  • PROTOCOL_UDP UDP Procotol
  • PROTOCOL_ICMP ICMP Procotol
  • PROTOCOL_ICMP6
  • PROTOCOL_ICMPV6 ICMPv6 Protocol
  • PROTOCOL_IP IP Protocol

Enumerates the socket address protocol options.


enum type
  • TYPE_NONE
  • TYPE_RAW Raw socket data
  • TYPE_STREAM Streaming socket data
  • TYPE_DGRAM Datagram socket data

Enumerates the socket address type options.


X

Thanks for Coming!

Subscribe to news and updates