/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: INetSrvSockets.hpp Date: 2022-8-15 Author: Reece ***/ #pragma once namespace Aurora::IO::Net { struct ISocketServer; struct NetSocketConnectByHost { NetHostname netHostname; AuUInt16 uPort; ETransportProtocol protocol; }; struct NetSocketConnectBase { inline NetSocketConnectBase() = default; inline NetSocketConnectBase(IPAddress ip, AuUInt16 uPort) : byEndpoint(NetEndpoint { ip, uPort }) { } inline NetSocketConnectBase(NetSocketConnectByHost byHost) : byHost(byHost) { } // connect by protocol, address:port AuOptionalEx byEndpoint; // or connect by [string/ip family, ip address], port AuOptionalEx byHost; }; struct NetSocketConnect : NetSocketConnectBase { inline NetSocketConnect() : NetSocketConnectBase() { } inline NetSocketConnect(IPAddress ip, AuUInt16 uPort) : NetSocketConnectBase(ip, uPort) { } inline NetSocketConnect(NetSocketConnectByHost byHost) : NetSocketConnectBase(byHost) { } AuSPtr pDriver; AuUInt32 uMaxConnectTimeMs {}; }; struct NetSocketConnectMany { AuList names; AuSPtr pDriver; AuUInt32 uMaxConnectTimeMs {}; }; struct NetSocketBind { ETransportProtocol protocol {}; IPAddress ip; AuUInt16 uPort {}; AuSPtr pFactory; AuSPtr pDriver; AuUInt32 uMaxConnections {}; AuUInt32 uMaxAcceptBacklog {}; AuUInt32 uDefaultInputStreamSize /* also: abs max datagram size of datagrams over sockets. note that each sessions buffer could be raised if tick/fragement future-buffering rejection. */ {}; bool bMultiThreaded {}; }; struct NetSocketBindEx : NetSocketBind { AuUInt32 uUDPTimeoutMs {}; }; struct INetSrvSockets { virtual AuSPtr Connect(const NetSocketConnect &netConnect) = 0; virtual AuSPtr ConnectMany(const NetSocketConnectMany &netConnectMany) = 0; virtual AuSPtr NewServer(const NetSocketBind &netBind) = 0; virtual AuSPtr NewServerEx(const NetSocketBindEx &netBindEx) = 0; }; };