Rise
The Vieneo Province
Loading...
Searching...
No Matches
isteamnetworkingsockets.h
Go to the documentation of this file.
1//====== Copyright Valve Corporation, All rights reserved. ====================
2
3#ifndef ISTEAMNETWORKINGSOCKETS
4#define ISTEAMNETWORKINGSOCKETS
5#pragma once
6
8#include "steam_api_common.h"
9
12class ISteamNetworkingConnectionSignaling;
13class ISteamNetworkingSignalingRecvContext;
15
16//-----------------------------------------------------------------------------
43{
44public:
45
65 virtual HSteamListenSocket CreateListenSocketIP( const SteamNetworkingIPAddr &localAddress, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
66
89 virtual HSteamNetConnection ConnectByIPAddress( const SteamNetworkingIPAddr &address, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
90
114 virtual HSteamListenSocket CreateListenSocketP2P( int nLocalVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
115
127 virtual HSteamNetConnection ConnectP2P( const SteamNetworkingIdentity &identityRemote, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
128
169
191 virtual bool CloseConnection( HSteamNetConnection hPeer, int nReason, const char *pszDebug, bool bEnableLinger ) = 0;
192
195 virtual bool CloseListenSocket( HSteamListenSocket hSocket ) = 0;
196
219 virtual bool SetConnectionUserData( HSteamNetConnection hPeer, int64 nUserData ) = 0;
220
224
226 virtual void SetConnectionName( HSteamNetConnection hPeer, const char *pszName ) = 0;
227
229 virtual bool GetConnectionName( HSteamNetConnection hPeer, char *pszName, int nMaxLen ) = 0;
230
268 virtual EResult SendMessageToConnection( HSteamNetConnection hConn, const void *pData, uint32 cbData, int nSendFlags, int64 *pOutMessageNumber ) = 0;
269
322 virtual void SendMessages( int nMessages, SteamNetworkingMessage_t **pMessages, int64 *pOutMessageNumberOrResult, bool bDeleteFailedMessages ) = 0;
323
338
354 virtual int ReceiveMessagesOnConnection( HSteamNetConnection hConn, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) = 0;
355
358
374 int nLanes, SteamNetConnectionRealTimeLaneStatus_t *pLanes ) = 0;
375
384 virtual int GetDetailedConnectionStatus( HSteamNetConnection hConn, char *pszBuf, int cbBuf ) = 0;
385
391
417 virtual bool CreateSocketPair( HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pPeerIdentity1, const SteamNetworkingIdentity *pPeerIdentity2 ) = 0;
418
486 virtual EResult ConfigureConnectionLanes( HSteamNetConnection hConn, int nNumLanes, const int *pLanePriorities, const uint16 *pLaneWeights ) = 0;
487
488 //
489 // Identity and authentication
490 //
491
497 virtual bool GetIdentity( SteamNetworkingIdentity *pIdentity ) = 0;
498
523
532
533 //
534 // Poll groups. A poll group is a set of connections that can be polled efficiently.
535 // (In our API, to "poll" a connection means to retrieve all pending messages. We
536 // actually don't have an API to "poll" the connection *state*, like BSD sockets.)
537 //
538
543
549 virtual bool DestroyPollGroup( HSteamNetPollGroup hPollGroup ) = 0;
550
565 virtual bool SetConnectionPollGroup( HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup ) = 0;
566
582 virtual int ReceiveMessagesOnPollGroup( HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) = 0;
583
584 //
585 // Clients connecting to dedicated servers hosted in a data center,
586 // using tickets issued by your game coordinator. If you are not
587 // issuing your own tickets to restrict who can attempt to connect
588 // to your server, then you won't use these functions.
589 //
590
595 virtual bool ReceivedRelayAuthTicket( const void *pvTicket, int cbTicket, SteamDatagramRelayAuthTicket *pOutParsedTicket ) = 0;
596
603 virtual int FindRelayAuthTicketForServer( const SteamNetworkingIdentity &identityGameServer, int nRemoteVirtualPort, SteamDatagramRelayAuthTicket *pOutParsedTicket ) = 0;
604
621 virtual HSteamNetConnection ConnectToHostedDedicatedServer( const SteamNetworkingIdentity &identityTarget, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
622
623 //
624 // Servers hosted in data centers known to the Valve relay network
625 //
626
635
639
666 virtual EResult GetHostedDedicatedServerAddress( SteamDatagramHostedAddress *pRouting ) = 0;
667
681 virtual HSteamListenSocket CreateHostedDedicatedServerListenSocket( int nLocalVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
682
713 virtual EResult GetGameCoordinatorServerLogin( SteamDatagramGameCoordinatorServerLogin *pLoginInfo, int *pcbSignedBlob, void *pBlob ) = 0;
714
715
716 //
717 // Relayed connections using custom signaling protocol
718 //
719 // This is used if you have your own method of sending out-of-band
720 // signaling / rendezvous messages through a mutually trusted channel.
721 //
722
756 virtual HSteamNetConnection ConnectP2PCustomSignaling( ISteamNetworkingConnectionSignaling *pSignaling, const SteamNetworkingIdentity *pPeerIdentity, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
757
787 virtual bool ReceivedP2PCustomSignal( const void *pMsg, int cbMsg, ISteamNetworkingSignalingRecvContext *pContext ) = 0;
788
789 //
790 // Certificate provision by the application. On Steam, we normally handle all this automatically
791 // and you will not need to use these advanced functions.
792 //
793
800 virtual bool GetCertificateRequest( int *pcbBlob, void *pBlob, SteamNetworkingErrMsg &errMsg ) = 0;
801
804 virtual bool SetCertificate( const void *pCertificate, int cbCertificate, SteamNetworkingErrMsg &errMsg ) = 0;
805
814 virtual void ResetIdentity( const SteamNetworkingIdentity *pIdentity ) = 0;
815
816 //
817 // Misc
818 //
819
825 virtual void RunCallbacks() = 0;
826
827 //
828 // "FakeIP" system.
829 //
830 // A FakeIP is essentially a temporary, arbitrary identifier that
831 // happens to be a valid IPv4 address. The purpose of this system is to make it
832 // easy to integrate with existing code that identifies hosts using IPv4 addresses.
833 // The FakeIP address will never actually be used to send or receive any packets
834 // on the Internet, it is strictly an identifier.
835 //
836 // FakeIP addresses are designed to (hopefully) pass through existing code as
837 // transparently as possible, while conflicting with "real" addresses that might
838 // be in use on networks (both the Internet and LANs) in the same code as little
839 // as possible. At the time this comment is being written, they come from the
840 // 169.254.0.0/16 range, and the port number will always be >1024. HOWEVER,
841 // this is subject to change! Do not make assumptions about these addresses,
842 // or your code might break in the future. In particular, you should use
843 // functions such as ISteamNetworkingUtils::IsFakeIP to determine if an IP
844 // address is a "fake" one used by this system.
845 //
846
887 virtual bool BeginAsyncRequestFakeIP( int nNumPorts ) = 0;
888
892 virtual void GetFakeIP( int idxFirstPort, SteamNetworkingFakeIPResult_t *pInfo ) = 0;
893
903 virtual HSteamListenSocket CreateListenSocketP2PFakeIP( int idxFakePort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
904
921
939 virtual ISteamNetworkingFakeUDPPort *CreateFakeUDPPort( int idxFakeServerPort ) = 0;
940
941protected:
942 ~ISteamNetworkingSockets(); // Silence some warnings
943};
944#define STEAMNETWORKINGSOCKETS_INTERFACE_VERSION "SteamNetworkingSockets013"
945
946// Global accessors
947
948// Using standalone lib
949#ifdef STEAMNETWORKINGSOCKETS_STANDALONELIB
950
951 static_assert( STEAMNETWORKINGSOCKETS_INTERFACE_VERSION[24] == '3', "Version mismatch" );
952 STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamNetworkingSockets_LibV13();
953 inline ISteamNetworkingSockets *SteamNetworkingSockets_Lib() { return SteamNetworkingSockets_LibV13(); }
954
955 STEAMNETWORKINGSOCKETS_INTERFACE ISteamNetworkingSockets *SteamGameServerNetworkingSockets_LibV13();
956 inline ISteamNetworkingSockets *SteamGameServerNetworkingSockets_Lib() { return SteamGameServerNetworkingSockets_LibV13(); }
957
958 #ifndef STEAMNETWORKINGSOCKETS_STEAMAPI
959 inline ISteamNetworkingSockets *SteamNetworkingSockets() { return SteamNetworkingSockets_LibV13(); }
960 inline ISteamNetworkingSockets *SteamGameServerNetworkingSockets() { return SteamGameServerNetworkingSockets_LibV13(); }
961 #endif
962#endif
963
964// Using Steamworks SDK
965#ifdef STEAMNETWORKINGSOCKETS_STEAMAPI
968
969 #ifndef STEAMNETWORKINGSOCKETS_STANDALONELIB
970 inline ISteamNetworkingSockets *SteamNetworkingSockets() { return SteamNetworkingSockets_SteamAPI(); }
971 inline ISteamNetworkingSockets *SteamGameServerNetworkingSockets() { return SteamGameServerNetworkingSockets_SteamAPI(); }
972 #endif
973#endif
974
976#if defined( VALVE_CALLBACK_PACK_SMALL )
977#pragma pack( push, 4 )
978#elif defined( VALVE_CALLBACK_PACK_LARGE )
979#pragma pack( push, 8 )
980#else
981#error "Must define VALVE_CALLBACK_PACK_SMALL or VALVE_CALLBACK_PACK_LARGE"
982#endif
983
1032
1052
1053#pragma pack( pop )
1054
1055#endif // ISTEAMNETWORKINGSOCKETS
virtual HSteamNetConnection ConnectToHostedDedicatedServer(const SteamNetworkingIdentity &identityTarget, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual EResult GetRemoteFakeIPForConnection(HSteamNetConnection hConn, SteamNetworkingIPAddr *pOutAddr)=0
virtual HSteamNetConnection ConnectP2P(const SteamNetworkingIdentity &identityRemote, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual HSteamNetPollGroup CreatePollGroup()=0
virtual uint16 GetHostedDedicatedServerPort()=0
virtual void GetFakeIP(int idxFirstPort, SteamNetworkingFakeIPResult_t *pInfo)=0
virtual bool GetConnectionInfo(HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo)=0
Returns basic information about the high-level state of the connection.
virtual bool BeginAsyncRequestFakeIP(int nNumPorts)=0
virtual bool SetConnectionUserData(HSteamNetConnection hPeer, int64 nUserData)=0
virtual int ReceiveMessagesOnPollGroup(HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages)=0
virtual bool DestroyPollGroup(HSteamNetPollGroup hPollGroup)=0
virtual bool GetIdentity(SteamNetworkingIdentity *pIdentity)=0
virtual HSteamNetConnection ConnectP2PCustomSignaling(ISteamNetworkingConnectionSignaling *pSignaling, const SteamNetworkingIdentity *pPeerIdentity, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual ESteamNetworkingAvailability GetAuthenticationStatus(SteamNetAuthenticationStatus_t *pDetails)=0
virtual ESteamNetworkingAvailability InitAuthentication()=0
virtual HSteamNetConnection ConnectByIPAddress(const SteamNetworkingIPAddr &address, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual EResult ConfigureConnectionLanes(HSteamNetConnection hConn, int nNumLanes, const int *pLanePriorities, const uint16 *pLaneWeights)=0
virtual bool SetConnectionPollGroup(HSteamNetConnection hConn, HSteamNetPollGroup hPollGroup)=0
virtual HSteamListenSocket CreateListenSocketP2P(int nLocalVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual void SetConnectionName(HSteamNetConnection hPeer, const char *pszName)=0
Set a name for the connection, used mostly for debugging.
virtual HSteamListenSocket CreateListenSocketIP(const SteamNetworkingIPAddr &localAddress, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual bool ReceivedRelayAuthTicket(const void *pvTicket, int cbTicket, SteamDatagramRelayAuthTicket *pOutParsedTicket)=0
virtual int GetDetailedConnectionStatus(HSteamNetConnection hConn, char *pszBuf, int cbBuf)=0
virtual bool GetListenSocketAddress(HSteamListenSocket hSocket, SteamNetworkingIPAddr *address)=0
virtual EResult SendMessageToConnection(HSteamNetConnection hConn, const void *pData, uint32 cbData, int nSendFlags, int64 *pOutMessageNumber)=0
virtual bool CloseConnection(HSteamNetConnection hPeer, int nReason, const char *pszDebug, bool bEnableLinger)=0
virtual bool GetCertificateRequest(int *pcbBlob, void *pBlob, SteamNetworkingErrMsg &errMsg)=0
virtual bool ReceivedP2PCustomSignal(const void *pMsg, int cbMsg, ISteamNetworkingSignalingRecvContext *pContext)=0
virtual EResult GetGameCoordinatorServerLogin(SteamDatagramGameCoordinatorServerLogin *pLoginInfo, int *pcbSignedBlob, void *pBlob)=0
virtual EResult FlushMessagesOnConnection(HSteamNetConnection hConn)=0
virtual bool SetCertificate(const void *pCertificate, int cbCertificate, SteamNetworkingErrMsg &errMsg)=0
virtual bool CreateSocketPair(HSteamNetConnection *pOutConnection1, HSteamNetConnection *pOutConnection2, bool bUseNetworkLoopback, const SteamNetworkingIdentity *pPeerIdentity1, const SteamNetworkingIdentity *pPeerIdentity2)=0
virtual HSteamListenSocket CreateListenSocketP2PFakeIP(int idxFakePort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual bool GetConnectionName(HSteamNetConnection hPeer, char *pszName, int nMaxLen)=0
Fetch connection name. Returns false if handle is invalid.
virtual void RunCallbacks()=0
virtual HSteamListenSocket CreateHostedDedicatedServerListenSocket(int nLocalVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions)=0
virtual SteamNetworkingPOPID GetHostedDedicatedServerPOPID()=0
virtual EResult GetHostedDedicatedServerAddress(SteamDatagramHostedAddress *pRouting)=0
virtual void ResetIdentity(const SteamNetworkingIdentity *pIdentity)=0
virtual bool CloseListenSocket(HSteamListenSocket hSocket)=0
virtual EResult AcceptConnection(HSteamNetConnection hConn)=0
virtual EResult GetConnectionRealTimeStatus(HSteamNetConnection hConn, SteamNetConnectionRealTimeStatus_t *pStatus, int nLanes, SteamNetConnectionRealTimeLaneStatus_t *pLanes)=0
virtual void SendMessages(int nMessages, SteamNetworkingMessage_t **pMessages, int64 *pOutMessageNumberOrResult, bool bDeleteFailedMessages)=0
virtual int FindRelayAuthTicketForServer(const SteamNetworkingIdentity &identityGameServer, int nRemoteVirtualPort, SteamDatagramRelayAuthTicket *pOutParsedTicket)=0
virtual int64 GetConnectionUserData(HSteamNetConnection hPeer)=0
virtual ISteamNetworkingFakeUDPPort * CreateFakeUDPPort(int idxFakeServerPort)=0
virtual int ReceiveMessagesOnConnection(HSteamNetConnection hConn, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages)=0
ISteamNetworkingSockets * SteamGameServerNetworkingSockets()
#define STEAMNETWORKINGSOCKETS_INTERFACE_VERSION
ISteamNetworkingSockets * SteamNetworkingSockets()
const char *typedef uint32(S_CALLTYPE *SteamAPI_CheckCallbackRegistered_t)(int iCallbackNum)
#define STEAM_DEFINE_USER_INTERFACE_ACCESSOR(type, name, version)
@ k_iSteamNetworkingSocketsCallbacks
#define STEAM_DEFINE_GAMESERVER_INTERFACE_ACCESSOR(type, name, version)
#define STEAMNETWORKINGSOCKETS_INTERFACE
uint32 HSteamNetConnection
Handle used to identify a connection to a remote host.
uint32 HSteamNetPollGroup
uint32 HSteamListenSocket
ESteamNetworkingAvailability
Describe the status of a particular network resource.
ESteamNetworkingConnectionState
High level connection status.
uint32 SteamNetworkingPOPID
char SteamNetworkingErrMsg[k_cchMaxSteamNetworkingErrMsg]
unsigned short uint16
Definition steamtypes.h:56
long long int64
Definition steamtypes.h:59
ESteamNetworkingAvailability m_eAvail
Status.
Describe the state of a connection.
Quick status of a particular lane.
Callback struct used to notify when a connection has changed state.
ESteamNetworkingConnectionState m_eOldState
Previous state. (Current state is in m_info.m_eState).
HSteamNetConnection m_hConn
Connection handle.
SteamNetConnectionInfo_t m_info
Full connection info.
Callback struct used to notify when a connection has changed state.
A message that has been received.