#include <xtd/collections/generic/list>
#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 socket = as<xtd::net::sockets::socket>(ar->async_state());
 
    
    auto counter = 0;
    while (!terminate_app) {
      auto str = string::format(
"socket={}, counter={}", 
socket.
handle(), ++counter);
 
      thread::sleep(50_ms);
    }
  };
  
  const size_t client_count = 10;
  
  auto server_socket = 
socket {address_family::inter_network, socket_type::stream, protocol_type::tcp};
 
  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) {
  }
  
  console::read_key();
  terminate_app = true;
}
 
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
 
const_iterator begin() const noexcept override
Returns an iterator to the first element of the enumarable.
Definition list.hpp:204
 
Represents a network endpoint as an IP address and a port number.
Definition ip_end_point.hpp:23
 
Implements the Berkeley sockets interface.
Definition socket.hpp:74
 
void bind(const end_point_t &local_end_point)
Associates a xtd::net::sockets::socket with a local endpoint.
Definition socket.hpp:798
 
size_t send(const std::vector< xtd::byte > &buffer)
Sends data to a connected xtd::net::sockets::socket.
 
intptr handle() const noexcept
Gets the operating system handle for the xtd::net::sockets::socket.
 
void end_connect(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous connection request.
 
size_t receive(std::vector< xtd::byte > &buffer)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
 
socket end_accept(xtd::sptr< xtd::iasync_result > async_result)
Asynchronously accepts an incoming connection attempt and creates a new xtd::net::sockets::socket::so...
 
xtd::sptr< xtd::iasync_result > begin_connect(const end_point_t &remote_end_point, xtd::async_callback callback, const std::any &state)
Begins an asynchronous request for a remote host connection.
Definition socket.hpp:581
 
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
 
delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:36
 
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:15
 
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:11
 
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:11
 
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10