2022-08-28 19:02:06 +00:00
/***
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 ;
2023-01-26 21:43:19 +00:00
struct NetSocketConnectByHost
{
2023-09-23 16:10:00 +00:00
NetHostname netHostname ;
AuUInt16 uPort ;
ETransportProtocol protocol ;
2023-01-26 21:43:19 +00:00
} ;
2023-09-23 18:33:08 +00:00
struct NetSocketConnectBase
2022-08-28 19:02:06 +00:00
{
2023-09-23 18:33:08 +00:00
inline NetSocketConnectBase ( ) = default ;
inline NetSocketConnectBase ( IPAddress ip , AuUInt16 uPort ) : byEndpoint ( NetEndpoint { ip , uPort } )
{ }
inline NetSocketConnectBase ( NetSocketConnectByHost byHost ) : byHost ( byHost )
{ }
2023-01-26 21:43:19 +00:00
// connect by protocol, address:port
2023-09-23 16:10:00 +00:00
AuOptionalEx < NetEndpoint > byEndpoint ;
2023-01-26 21:43:19 +00:00
// or connect by [string/ip family, ip address], port
2023-09-23 16:10:00 +00:00
AuOptionalEx < NetSocketConnectByHost > byHost ;
2023-09-23 18:33:08 +00:00
} ;
struct NetSocketConnect : NetSocketConnectBase
{
inline NetSocketConnect ( ) :
NetSocketConnectBase ( )
{ }
inline NetSocketConnect ( IPAddress ip , AuUInt16 uPort ) :
NetSocketConnectBase ( ip , uPort )
{ }
inline NetSocketConnect ( NetSocketConnectByHost byHost ) :
NetSocketConnectBase ( byHost )
{ }
2023-01-26 21:43:19 +00:00
2022-08-28 19:02:06 +00:00
AuSPtr < ISocketDriver > pDriver ;
2022-09-02 19:53:25 +00:00
AuUInt32 uMaxConnectTimeMs { } ;
2022-08-28 19:02:06 +00:00
} ;
struct NetSocketConnectMany
{
2023-09-23 18:33:08 +00:00
AuList < NetSocketConnectBase > names ;
2022-08-28 19:02:06 +00:00
AuSPtr < ISocketDriver > pDriver ;
AuUInt32 uMaxConnectTimeMs { } ;
} ;
struct NetSocketBind
{
2022-09-27 16:30:26 +00:00
ETransportProtocol protocol { } ;
2022-08-28 19:02:06 +00:00
IPAddress ip ;
AuUInt16 uPort { } ;
AuSPtr < ISocketDriverFactory > pFactory ;
AuSPtr < ISocketServerDriver > pDriver ;
2022-12-16 17:18:12 +00:00
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. */ { } ;
2022-12-12 23:50:05 +00:00
bool bMultiThreaded { } ;
2022-08-28 19:02:06 +00:00
} ;
struct NetSocketBindEx : NetSocketBind
{
AuUInt32 uUDPTimeoutMs { } ;
} ;
struct INetSrvSockets
{
virtual AuSPtr < ISocket > Connect ( const NetSocketConnect & netConnect ) = 0 ;
virtual AuSPtr < ISocket > ConnectMany ( const NetSocketConnectMany & netConnectMany ) = 0 ;
virtual AuSPtr < ISocketServer > NewServer ( const NetSocketBind & netBind ) = 0 ;
virtual AuSPtr < ISocketServer > NewServerEx ( const NetSocketBindEx & netBindEx ) = 0 ;
} ;
} ;