Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.network.classic

Class EM_INET_SOCKET_ADDRESS


Direct ancestors

EM_INET_ADDRESS, EM_NETWORK_HELPER_FUNCTIONS, EM_NETWORK_CONSTANTS, EM_SHARED_SUBSYSTEMS, SDL_NET_FUNCTIONS_EXTERNAL

Creation

Features

Invariants

indexing

description

Representation of an internet socket address which consists of an
internet address and a port.

This class uses IPv4 internet addresses since there is no SDL
network implementation that supports IPv6 at the moment.

date

$Date: 2005/10/25 20:11:44 $

revision

$Revision: 1.27 $

class

EM_INET_SOCKET_ADDRESS

inherit

EM_INET_ADDRESS

create

make_local_by_port (a_port: INTEGER)

-- Creates a new IPv4 socket address for all local network interfaces.

require
networking_enabled: network_subsystem.is_enabled
port_in_range: a_port >= 0 and a_port <= 65535
ensure
port_set: port = a_port
make_by_hostname_port (a_host: STRING; a_port: INTEGER)

-- Creates a new IPv4 socket address
-- a_host can be a full qualified hostname or an IPv4 address
-- in textual representation (x.x.x.x).

require
networking_enabled: network_subsystem.is_enabled
host_not_void: a_host /= Void
port_in_range: a_port >= 0 and a_port <= 65535
ensure
hostname_set: hostname = a_host
port_set: port = a_port
make_by_ip_port (a_host_ip: INTEGER; a_port: INTEGER)

-- Creates a new IPv4 socket address based on a_host_ip.
-- This tries to reverse resolve a_host_ip to a hostname.
-- If this fails, hostname will be an empty string.

require
networking_enabled: network_subsystem.is_enabled
port_in_range: a_port >= 0 and a_port <= 65535
ensure
address_set: host_ip = a_host_ip
port_set: port = a_port
make_by_ip_string_port (a_host_ip_string: STRING; a_port: INTEGER)

-- Creates a new IPv4 address from a_host_ip_string
-- Does not reverse resolve a_host_ip_string.

require
a_host_ip_string_not_void: a_host_ip_string /= Void
port_in_range: a_port >= 0 and a_port <= 65535
ensure
no_error_occured: True
port_set: a_port = port
make_by_inet_address_port (an_inet_address: EM_INET_ADDRESS; a_port: INTEGER)

-- Create a new inet socket address.

require
an_inet_address_not_void: an_inet_address /= Void
port_in_range: a_port >= 0 and a_port <= 65535
ensure
hostname_set: hostname.is_equal (an_inet_address.hostname)
host_ip_set: host_ip = an_inet_address.host_ip
port_set: port = a_port

create {EM_SIMPLE_UDP_SOCKET, EM_UDP_PACKET, EM_SOCKET}

make_by_struct (an_ip_address_struct: IPADDRESS_STRUCT)

-- Create a new IPv4 socket address from an_ip_address_struct

require
an_ip_address_struct_not_void: an_ip_address_struct /= Void
ensure
host_ip_set: host_ip = convert_from_big_endian_32 (an_ip_address_struct.host)
port_set: port = convert_from_big_endian_16 (an_ip_address_struct.port)

feature -- Access

network_subsystem: EM_NETWORK_SUBSYSTEM

-- EiffelMedia network subsystem is

-- (From EM_SHARED_SUBSYSTEMS)

ensure
network_subsystem_not_void: Result /= void
host_ip: INTEGER

-- Host IPv4

-- (From EM_INET_ADDRESS)

hostname: STRING

-- Hostname

-- (From EM_INET_ADDRESS)

port: INTEGER

-- The port of the socket address.

feature -- Status setting

resolve_blocking

-- Resolve host_ip from hostname.
-- This feature is blocking.

-- (From EM_INET_ADDRESS)

require
not_is_resolved: not is_resolved
is_reverse_resolved: is_reverse_resolved
resolve_non_blocking

-- Resolve host_ip from hostname.
-- This feature is non-blocking.
-- Subscribe to the resolve_finished_event and use is_resolved which indicates success or failure.

-- (From EM_INET_ADDRESS)

require
not_is_resolved: not is_resolved
is_reverse_resolved: is_reverse_resolved
reverse_resolve_blocking

-- Reverse resolve hostname from host_ip
-- This feature is blocking.

-- (From EM_INET_ADDRESS)

require
not_is_reverse_resolved: not is_reverse_resolved
is_resolved: is_resolved

feature -- Conversion

host_ip_as_string: STRING

-- Host IP in textual representation (xy.xy.xy.xy)

-- (From EM_INET_ADDRESS)

host_ip_port_as_string: STRING

-- Host IP and port in textual representation (xy.xy.xy.xy:port)

to_hex_string: STRING

-- Hexadezimal represenatation of ip and port

-- (From EM_INET_ADDRESS)

feature -- Events

feature -- Status

is_resolved: BOOLEAN

-- Is host_ip resolved?
-- Is host_ip ready for usage?

-- (From EM_INET_ADDRESS)

is_reverse_resolved: BOOLEAN

-- Is hostname reverse resolved?
-- Ist hostname ready for usage?

-- (From EM_INET_ADDRESS)

feature {EM_SOCKETS, EM_SOCKET, EM_UDP_PACKET} -- Implementation

ip_address_struct: IPADDRESS_STRUCT

-- IP Address Struct

-- (From EM_INET_ADDRESS)

invariant

port_in_range: port >= 0 and port <= 65535

hostname_set: hostname /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end