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

em.network.classic

Class EM_SIMPLE_UDP_SOCKET


Direct ancestors

EM_SHARED_ERROR_HANDLER, EM_NETWORK_CONSTANTS, EM_SHARED_SUBSYSTEMS, SDL_NET_FUNCTIONS, SDL_ERROR_FUNCTIONS, DISPOSABLE, EXCEPTIONS

Creation

Features

Invariants

indexing

description

A UDP socket that can be used to send or receive data over a network using the non-reliable
UDP protocol.

date

$Date$

revision

$Revision$

class

EM_SIMPLE_UDP_SOCKET

inherit

DISPOSABLE

create

make

-- Creates a new UDP socket.

feature -- Open/Close

close

-- Closes the current socket.

require
open: is_open
ensure
not_open: not is_open
open (a_port: INTEGER)

-- Opens the socket for listening on a_port.

require
a_port_in_range: a_port > 0 and a_port < 65536
not_open: not is_open
ensure
open: is_open
no_error_occured: not error_handler.has_error_occured

feature -- Send/Receive

is_packet_ready: BOOLEAN

-- Is packet ready?
-- If a packet is ready you usually want to call the command reveice_packet afterwards.
-- Use this function in an eventloop for example: Receive a packet and generate an event.
-- You should generally not use a seperate thread to poll for packets because this feature is non-blocking.

require
open: is_open
ensure
no_error_occured: not error_handler.has_error_occured
receive_packet

-- Receive a packet.
-- You can get the packet using the query last_packet.

require
open: is_open
packet_ready: is_packet_ready
send (a_packet: EM_UDP_PACKET)

-- Send a_packet to its destination.

require
open: is_open

feature -- Status

is_open: BOOLEAN

-- True if the socket is opened for listening on a local port.

last_packet: EM_UDP_PACKET

-- Last received packet

invariant

network_initialized: network_subsystem.is_enabled

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

end