#include <xtd/net/sockets/socket>
#include <xtd/net/ip_end_point>
#include <xtd/threading/thread>
#include <xtd/as>
#include <xtd/console>
auto main() -> int {
auto terminate_app = false;
while (!terminate_app) {
if (number_of_byte_received)
console::write_line(
string {buffer.begin(), buffer.begin() + number_of_byte_received});
}
};
auto counter = 0;
while (!terminate_app) {
auto str = string::format(
"socket={}, counter={}",
socket.
handle(), ++counter);
}
};
const size_t client_count = 10;
server_socket.listen();
for (auto index = 0_z; index < client_count; ++index)
server_socket.begin_accept(
async_callback(on_server_accept), server_socket);
for (auto index = 0_z; index < client_count; ++index) {
}
terminate_app = true;
}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
static console_key_info read_key()
Obtains the next character or function key pressed by the user. The pressed key is displayed in the c...
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static const ip_address any
Provides an IP address that indicates that the server must listen for client activity on all network ...
Definition ip_address.hpp:49
static const ip_address loopback
Provides the IP loopback address. This field is constant.
Definition ip_address.hpp:65
Represents a network endpoint as an IP address and a port number.
Definition ip_end_point.hpp:28
Implements the Berkeley sockets interface.
Definition socket.hpp:77
void bind(const end_point_t &local_end_point)
Associates a xtd::net::sockets::socket with a local endpoint.
Definition socket.hpp:801
intptr handle() const noexcept
Gets the operating system handle for the xtd::net::sockets::socket.
size_t send(const xtd::array< xtd::byte > &buffer)
Sends data to a connected xtd::net::sockets::socket.
void end_connect(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous connection request.
xtd::sptr< xtd::iasync_result > begin_connect(const end_point_t &remote_end_point, xtd::async_callback callback, const xtd::any_object &state)
Begins an asynchronous request for a remote host connection.
Definition socket.hpp:584
size_t receive(xtd::array< xtd::byte > &buffer)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
static void sleep(int32 milliseconds_timeout)
Suspends the current thread for a specified time.
xtd::delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:39
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ inter_network
Address for IP version 4.
Definition address_family.hpp:38
@ socket
Socket options apply to all sockets.
Definition socket_option_level.hpp:33
@ tcp
Transmission Control Protocol.
Definition protocol_type.hpp:48
@ stream
Supports reliable, two-way, connection-based byte streams without the duplication of data and without...
Definition socket_type.hpp:36
The xtd::net::sockets namespace provides a managed implementation of the Berkeley Sockets interface f...
Definition address_family.hpp:16
The xtd::net namespace provides a simple programming interface for many of the protocols used on netw...
Definition cookie_exception.hpp:10
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8