INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Generic socket encapsulating API operations"
project: "Visual Eiffel Library"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: sockets
deferred class ESL_SOCKET
inherit

ESL_SOCKETS_API
redefine
is_equal
end

ESL_SOCKETS_CONST
redefine
is_equal
end

ESL_SOCKETS_EXCEPTIONS
redefine
is_equal
end

MEMORY
redefine
dispose,
is_equal
end
feature -- Queries

is_bound: BOOLEAN

is_connected: BOOLEAN

is_valid: BOOLEAN
-- Is `handle' initialized with a valid value?

type: INTEGER
-- Type of the socket
feature -- Comparison

is_equal (other: like Current): BOOLEAN
-- Is `Current' equal to `other'?
feature -- Socket creation

make
-- Create a new socket
ensure
is_valid: is_valid

make_bound (local_addr: ESL_INTERNET_HOST_ADDRESS; local_port: INTEGER)
-- Create a new socket and bind it to the specified address & port
ensure
is_valid: is_valid
is_bound: is_bound

make_connected (remote_addr: ESL_INTERNET_HOST_ADDRESS; remote_port: INTEGER)
-- Create a new socket and connect it to the specified peer address
ensure
is_valid: is_valid
is_connected: is_connected

make_bound_and_connected (local_addr: ESL_INTERNET_HOST_ADDRESS; local_port: INTEGER; remote_addr: ESL_INTERNET_HOST_ADDRESS; remote_port: INTEGER)
-- Create a new socket, bind it to the `local_addr' & `local_port'
-- and connect it to the `remote_addr' & `remote_port'
ensure
is_valid: is_valid
is_bound: is_bound
is_connected: is_connected
feature -- Address queries

get_local_address: ESL_INTERNET_HOST_ADDRESS
-- Retrieve the address to which the socket is (to be) bound

get_remote_address: ESL_INTERNET_HOST_ADDRESS
-- Retrieve the address to which the socket is (to be) connected

get_local_port: INTEGER

get_remote_port: INTEGER
feature -- Address assignment

set_local_address (new_address: ESL_INTERNET_HOST_ADDRESS)
-- Assign a certain `new_address' to the local address of the socket.
-- The `new_address' will further be used for binding.
require
is_unbound: not is_bound

set_remote_address (new_address: ESL_INTERNET_HOST_ADDRESS)
-- Assign a certain `new_address' to the remote address of the socket.
-- The `new_address' will further be used for connecting.
require
not_connected: not is_connected

set_local_port (new_port: INTEGER)

set_remote_port (new_port: INTEGER)
feature -- Operations

bind
-- Associate a local address with the socket.
-- `bind' may complete abruptly with exception code
-- `E_socket_bind_exception' when the system fails to bind the
-- socket to the specified address.
require
is_valid: is_valid
is_unbound: not is_bound
ensure
is_bound: is_bound

connect
-- Establish a connection to a peer
require
is_valid: is_valid
not_connected: not is_connected
ensure
is_connected: is_connected
is_bound: is_bound
feature -- Data exchange

receive_data (buf: STRING; flags: BIT 32): INTEGER
-- Receive data from the socket into the `buf'.
-- Number of characters actually received is returned.
-- If connection is closed, zero is returned.
-- `receive_data' may complete abruptly with exception code
-- `E_socket_receive_exception' if any communication error
-- has been occurred.
require
good_buffer: (buf /= void) and then not buf.is_empty
is_valid: is_valid
ensure
non_negative_result: Result >= 0

send_data (buf: STRING; flags: BIT 32): INTEGER
-- Send data on the connected socket
-- Number of characters actually sent is returned
-- `send_data' may complete abruptly with exception code
-- `E_socket_send_exception' if any communication error
-- has been occurred.
require
good_buffer: buf /= void
is_valid: is_valid
ensure
non_negative_result: Result >= 0
feature -- Data status

available: INTEGER
-- Number of characters that can be read without blocking
feature -- Shutdown

close
-- Close the socket
require
is_valid: is_valid
ensure
is_invalid: not is_valid

shutdown (how: INTEGER)
-- Disable send or receive operations on the socket.
-- If `how' is 0, subsequent receives on the socket will be disallowed.
-- If `how' is 1, subsequent sends are disallowed.
-- Setting `how' to 2 disables both sends and receives.
-- NOTE: `shutdown' does not close the socket.
require
is_valid: is_valid
valid_entry: (how = 0) or (how = 1) or (how = 2)
end -- class ESL_SOCKET

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES