socket_address
|
 |
An os_socket_address
represents an address of a socket endpoint on a machine. Socket addresses are
used for the following primary purposes.
- As addresses for
construction of an
os_tcp_socket or os_tcp_connection_server
- As an argument for
connect_to()
- As an argument for
send_to()
or receive_from() used with UDP sockets
Conversions permit
interchangeable use of os_socket_address and sockaddr_in.
Declaration
#include <ospace/network/sockaddr.h>
class os_socket_address
Interface
Constructor
os_socket_address(
int n )
Constructs
a socket address that represents port n (default 0
) on the local host.
Constructor
os_socket_address(
const sockaddr_in& address )
Constructs
a socket address from the encoded IP value address
.
Constructor
os_socket_address(
const os_ip_address& address ,
int n )
Constructs
a socket address that represents port n (default 0
) at IP address address .
Constructor
os_socket_address(
const os_socket_address& address )
Constructs
a socket address with the same value as address .
<
bool
operator<( const os_socket_address& address
) const
Returns
true if this socket value is less than address
.
=
os_socket_address&
operator=( const os_socket_address& address )
Assigns this socket
address to address .
=
os_socket_address&
operator=( const sockaddr_in& address )
Assigns
this socket address to address .
==
bool
operator==( const os_socket_address& address
) const
Returns
true if this socket address is the same as address
.
(sockaddr_in)
operator
sockaddr_in() const
Returns
this socket address as a sockaddr_in structure.
defined
bool
defined() const
Returns
true if the port number is non-zero.
domain
short
domain() const
Returns
the domain.
ip_address
os_ip_address
ip_address() const
Returns
the IP address.
ip_address
void
ip_address( const os_ip_address& address
)
Sets
the IP address to address .
port
void
port( int port )
Sets
the port to port .
port
int
port() const
Returns
the port number.
print
void
print( ostream& stream )
const
Prints
the IP address and port to stream .
Non-Member Functions
<<
ostream&
operator<<( ostream& stream ,
const os_socket_address& address )
Prints address
to stream .
Universal Streaming Service
#include <ospace/uss/network.h>
<<
os_bstream&
operator<<( os_bstream& stream ,
const os_socket_address& address )
Writes address
to stream .
>>
os_bstream&
operator>>( os_bstream& stream ,
os_socket_address& address )
Reads address
from stream .
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.