engine
 
载入中...
搜索中...
未找到
Public 成员函数 | Protected 属性 | 所有成员列表
FSocket类 参考abstract

This is our abstract base class that hides the platform specific socket implementation 更多...

#include <Sockets.h>

Public 成员函数

virtual class FSocket * Accept (const FString &InSocketDescription)=0
 Accepts a connection that is pending. 更多...
 
virtual class FSocket * Accept (FInternetAddr &OutAddr, const FString &InSocketDescription)=0
 Accepts a connection that is pending. 更多...
 
virtual bool Bind (const FInternetAddr &Addr)=0
 Binds a socket to a network byte ordered address. 更多...
 
virtual bool Close ()=0
 Closes the socket 更多...
 
virtual bool Connect (const FInternetAddr &Addr)=0
 Connects a socket to a network byte ordered address. 更多...
 
 FSocket ()
 Default constructor.
 
 FSocket (ESocketType InSocketType, const FString &InSocketDescription)
 Specifies the type of socket being created 更多...
 
 FSocket (ESocketType InSocketType, const FString &InSocketDescription, const FName &InSocketProtocol)
 Specifies the type of socket being created 更多...
 
virtual void GetAddress (FInternetAddr &OutAddr)=0
 Reads the address the socket is bound to and returns it. 更多...
 
virtual ESocketConnectionState GetConnectionState ()=0
 Determines the connection state of the socket. 更多...
 
FORCEINLINE FString GetDescription () const
 Get the debug description of the socket. 更多...
 
virtual bool GetPeerAddress (FInternetAddr &OutAddr)=0
 Reads the address of the peer the socket is connected to. 更多...
 
virtual int32 GetPortNo ()=0
 Reads the port this socket is bound to. 更多...
 
FORCEINLINE FName GetProtocol () const
 Get the type of protocol the socket is bound to 更多...
 
FORCEINLINE ESocketType GetSocketType () const
 Get the type of protocol the socket is bound to 更多...
 
bool HasPendingConnection (bool &bHasPendingConnection)
 Queries the socket to determine if there is a pending connection. 更多...
 
virtual bool HasPendingData (uint32 &PendingDataSize)=0
 Queries the socket to determine if there is pending data on the queue. 更多...
 
virtual bool JoinMulticastGroup (const FInternetAddr &GroupAddress)=0
 Joins this socket to the specified multicast group. 更多...
 
virtual bool JoinMulticastGroup (const FInternetAddr &GroupAddress, const FInternetAddr &InterfaceAddress)=0
 Joins this socket to the specified multicast group on the specified interface. 更多...
 
virtual bool LeaveMulticastGroup (const FInternetAddr &GroupAddress)=0
 Removes this UDP client from the specified multicast group. 更多...
 
virtual bool LeaveMulticastGroup (const FInternetAddr &GroupAddress, const FInternetAddr &InterfaceAddress)=0
 Removes this UDP client from the specified multicast group on the specified interface. 更多...
 
virtual bool Listen (int32 MaxBacklog)=0
 Places the socket into a state to listen for incoming connections. 更多...
 
virtual bool Recv (uint8 *Data, int32 BufferSize, int32 &BytesRead, ESocketReceiveFlags::Type Flags=ESocketReceiveFlags::None)
 Reads a chunk of data from a connected socket 更多...
 
virtual bool RecvFrom (uint8 *Data, int32 BufferSize, int32 &BytesRead, FInternetAddr &Source, ESocketReceiveFlags::Type Flags=ESocketReceiveFlags::None)
 Reads a chunk of data from the socket and gathers the source address. 更多...
 
virtual bool RecvMulti (FRecvMulti &MultiData, ESocketReceiveFlags::Type Flags=ESocketReceiveFlags::None)
 Reads multiple packets from the socket at once, gathering the source address and other optional platform specific data. 更多...
 
virtual bool Send (const uint8 *Data, int32 Count, int32 &BytesSent)
 Sends a buffer on a connected socket. 更多...
 
virtual bool SendTo (const uint8 *Data, int32 Count, int32 &BytesSent, const FInternetAddr &Destination)
 Sends a buffer to a network byte ordered address. 更多...
 
virtual bool SetBroadcast (bool bAllowBroadcast=true)=0
 Sets a socket into broadcast mode (UDP only). 更多...
 
virtual bool SetLinger (bool bShouldLinger=true, int32 Timeout=0)=0
 Sets whether and how long a socket will linger after closing. 更多...
 
virtual bool SetMulticastInterface (const FInternetAddr &InterfaceAddress)=0
 Sets the interface used to send outgoing multicast datagrams. 更多...
 
virtual bool SetMulticastLoopback (bool bLoopback)=0
 Enables or disables multicast loopback on the socket (UDP only). 更多...
 
virtual bool SetMulticastTtl (uint8 TimeToLive)=0
 Sets the time to live (TTL) for multicast datagrams. 更多...
 
virtual bool SetNoDelay (bool bIsNoDelay=true)=0
 Sets this socket into TCP_NODELAY mode (TCP only). 更多...
 
virtual bool SetNonBlocking (bool bIsNonBlocking=true)=0
 Sets this socket into non-blocking mode. 更多...
 
virtual bool SetReceiveBufferSize (int32 Size, int32 &NewSize)=0
 Sets the size of the receive buffer to use. 更多...
 
virtual bool SetRecvErr (bool bUseErrorQueue=true)=0
 Enables error queue support for the socket. 更多...
 
virtual bool SetRetrieveTimestamp (bool bRetrieveTimestamp=true)
 Sets whether to retrieve the system-level receive timestamp, for sockets 更多...
 
virtual bool SetReuseAddr (bool bAllowReuse=true)=0
 Sets whether a socket can be bound to an address in use. 更多...
 
virtual bool SetSendBufferSize (int32 Size, int32 &NewSize)=0
 Sets the size of the send buffer to use. 更多...
 
virtual bool Shutdown (ESocketShutdownMode Mode)=0
 Shuts down the socket, making it unusable for reads and/or writes. 更多...
 
virtual bool Wait (ESocketWaitConditions::Type Condition, FTimespan WaitTime)=0
 Blocks until the specified condition is met. 更多...
 
virtual bool WaitForPendingConnection (bool &bHasPendingConnection, const FTimespan &WaitTime)=0
 Waits for a pending connection on the socket. 更多...
 
virtual ~FSocket ()
 Virtual destructor.
 

Protected 属性

FString SocketDescription
 Debug description of socket usage.
 
FName SocketProtocol
 Protocol used in creation of a socket
 
const ESocketType SocketType
 Indicates the type of socket this is
 

详细描述

This is our abstract base class that hides the platform specific socket implementation

构造及析构函数说明

◆ FSocket() [1/2]

FSocket::FSocket ( ESocketType  InSocketType,
const FString &  InSocketDescription 
)
inline

Specifies the type of socket being created

参数
InSocketTypeThe type of socket being created
InSocketDescriptionThe debug description of the socket

◆ FSocket() [2/2]

FSocket::FSocket ( ESocketType  InSocketType,
const FString &  InSocketDescription,
const FName &  InSocketProtocol 
)
inline

Specifies the type of socket being created

参数
InSocketTypeThe type of socket being created
InSocketDescriptionThe debug description of the socket
InSocketProtocolthe protocol stack this socket should be created on.

成员函数说明

◆ Accept() [1/2]

virtual class FSocket * FSocket::Accept ( const FString &  InSocketDescription)
pure virtual

Accepts a connection that is pending.

参数
SocketDescriptionDebug description of socket,
返回
The new (heap-allocated) socket, or nullptr if unsuccessful.

◆ Accept() [2/2]

virtual class FSocket * FSocket::Accept ( FInternetAddr &  OutAddr,
const FString &  InSocketDescription 
)
pure virtual

Accepts a connection that is pending.

参数
OutAddrThe address of the connection.
SocketDescriptionDebug description of socket.
返回
The new (heap-allocated) socket, or nullptr if unsuccessful.

◆ Bind()

virtual bool FSocket::Bind ( const FInternetAddr &  Addr)
pure virtual

Binds a socket to a network byte ordered address.

参数
AddrThe address to bind to.
返回
true if successful, false otherwise.

◆ Close()

virtual bool FSocket::Close ( )
pure virtual

Closes the socket

返回
true if it closes without errors, false otherwise.

◆ Connect()

virtual bool FSocket::Connect ( const FInternetAddr &  Addr)
pure virtual

Connects a socket to a network byte ordered address.

参数
AddrThe address to connect to.
返回
true if successful, false otherwise.

◆ GetAddress()

virtual void FSocket::GetAddress ( FInternetAddr &  OutAddr)
pure virtual

Reads the address the socket is bound to and returns it.

参数
OutAddrThe address the socket is bound to.

◆ GetConnectionState()

virtual ESocketConnectionState FSocket::GetConnectionState ( )
pure virtual

Determines the connection state of the socket.

返回
Connection state.

◆ GetDescription()

FORCEINLINE FString FSocket::GetDescription ( ) const
inline

Get the debug description of the socket.

返回
Debug string.
参见
GetPortNo, GetSocketType

◆ GetPeerAddress()

virtual bool FSocket::GetPeerAddress ( FInternetAddr &  OutAddr)
pure virtual

Reads the address of the peer the socket is connected to.

参数
OutAddrAddress of the peer the socket is connected to.
返回
true if the address was retrieved correctly, false otherwise.

◆ GetPortNo()

virtual int32 FSocket::GetPortNo ( )
pure virtual

Reads the port this socket is bound to.

返回
Port number.
参见
GetSocketType, GetDescription

◆ GetProtocol()

FORCEINLINE FName FSocket::GetProtocol ( ) const
inline

Get the type of protocol the socket is bound to

返回
Socket type.
参见
GetDescription, GetPortNo

◆ GetSocketType()

FORCEINLINE ESocketType FSocket::GetSocketType ( ) const
inline

Get the type of protocol the socket is bound to

返回
Socket type.
参见
GetDescription, GetPortNo

◆ HasPendingConnection()

bool FSocket::HasPendingConnection ( bool &  bHasPendingConnection)
inline

Queries the socket to determine if there is a pending connection.

参数
bHasPendingConnectionWill indicate whether a connection is pending or not.
返回
true if successful, false otherwise.

◆ HasPendingData()

virtual bool FSocket::HasPendingData ( uint32 &  PendingDataSize)
pure virtual

Queries the socket to determine if there is pending data on the queue.

参数
PendingDataSizeWill indicate how much data is on the pipe for a single recv call.
返回
true if the socket has data, false otherwise.

◆ JoinMulticastGroup() [1/2]

virtual bool FSocket::JoinMulticastGroup ( const FInternetAddr &  GroupAddress)
pure virtual

Joins this socket to the specified multicast group.

The multicast group address must be in the range 224.0.0.0 to 239.255.255.255.

参数
GroupAddressThe IP address of the multicast group.
返回
true on success, false otherwise.
参见
LeaveMulticastGroup, SetMulticastLoopback, SetMulticastTtl

◆ JoinMulticastGroup() [2/2]

virtual bool FSocket::JoinMulticastGroup ( const FInternetAddr &  GroupAddress,
const FInternetAddr &  InterfaceAddress 
)
pure virtual

Joins this socket to the specified multicast group on the specified interface.

The multicast group address must be in the range 224.0.0.0 to 239.255.255.255.

参数
GroupAddressThe IP address of the multicast group.
InterfaceAddressThe address representing the interface.
返回
true on success, false otherwise.
参见
LeaveMulticastGroup, SetMulticastLoopback, SetMulticastTtl

◆ LeaveMulticastGroup() [1/2]

virtual bool FSocket::LeaveMulticastGroup ( const FInternetAddr &  GroupAddress)
pure virtual

Removes this UDP client from the specified multicast group.

参数
Themulticast group address to leave.
返回
true on success, false otherwise.
参见
JoinMulticastGroup, SetMulticastLoopback, SetMulticastTtl

◆ LeaveMulticastGroup() [2/2]

virtual bool FSocket::LeaveMulticastGroup ( const FInternetAddr &  GroupAddress,
const FInternetAddr &  InterfaceAddress 
)
pure virtual

Removes this UDP client from the specified multicast group on the specified interface.

参数
GroupAddressThe multicast group address to leave.
InterfaceAddressThe address representing the interface.
返回
true on success, false otherwise.
参见
JoinMulticastGroup, SetMulticastLoopback, SetMulticastTtl

◆ Listen()

virtual bool FSocket::Listen ( int32  MaxBacklog)
pure virtual

Places the socket into a state to listen for incoming connections.

参数
MaxBacklogThe number of connections to queue before refusing them.
返回
true if successful, false otherwise.

◆ Recv()

virtual bool FSocket::Recv ( uint8 *  Data,
int32  BufferSize,
int32 &  BytesRead,
ESocketReceiveFlags::Type  Flags = ESocketReceiveFlags::None 
)
virtual

Reads a chunk of data from a connected socket

A return value of 'true' does not necessarily mean that data was returned. Callers must check the 'BytesRead' parameter for the actual amount of data returned. A value of zero indicates that there was no data available for reading.

参数
DataThe buffer to read into
BufferSizeThe max size of the buffer
BytesReadWill indicate how many bytes were read from the socket
Flagsthe receive flags
返回
true on success, false in case of a closed socket or an unrecoverable error.

◆ RecvFrom()

virtual bool FSocket::RecvFrom ( uint8 *  Data,
int32  BufferSize,
int32 &  BytesRead,
FInternetAddr &  Source,
ESocketReceiveFlags::Type  Flags = ESocketReceiveFlags::None 
)
virtual

Reads a chunk of data from the socket and gathers the source address.

A return value of 'true' does not necessarily mean that data was returned. Callers must check the 'BytesRead' parameter for the actual amount of data returned. A value of zero indicates that there was no data available for reading.

参数
DataThe buffer to read into.
BufferSizeThe max size of the buffer.
BytesReadWill indicate how many bytes were read from the socket.
SourceWill contain the receiving the address of the sender of the data.
FlagsThe receive flags.
返回
true on success, false in case of a closed socket or an unrecoverable error.

◆ RecvMulti()

virtual bool FSocket::RecvMulti ( FRecvMulti &  MultiData,
ESocketReceiveFlags::Type  Flags = ESocketReceiveFlags::None 
)
virtual

Reads multiple packets from the socket at once, gathering the source address and other optional platform specific data.

Use ISocketSubsystem::IsSocketRecvMultiSupported to check if the current socket platform supports this. NOTE: For optimal performance, one FRecvMulti instance should be used, for the lifetime of the socket.

参数
MultiDataThe FRecvMulti instance that receives packet data and holds platform specific buffers for receiving data.
FlagsThe receive flags.
返回
Whether or not data was successfully received

◆ Send()

virtual bool FSocket::Send ( const uint8 *  Data,
int32  Count,
int32 &  BytesSent 
)
virtual

Sends a buffer on a connected socket.

参数
DataThe buffer to send.
CountThe size of the data to send.
BytesSentWill indicate how much was sent.

◆ SendTo()

virtual bool FSocket::SendTo ( const uint8 *  Data,
int32  Count,
int32 &  BytesSent,
const FInternetAddr &  Destination 
)
virtual

Sends a buffer to a network byte ordered address.

参数
DataThe buffer to send.
CountThe size of the data to send.
BytesSentWill indicate how much was sent.
DestinationThe network byte ordered address to send to.

◆ SetBroadcast()

virtual bool FSocket::SetBroadcast ( bool  bAllowBroadcast = true)
pure virtual

Sets a socket into broadcast mode (UDP only).

参数
bAllowBroadcastWhether to enable broadcast or not.
返回
true if successful, false otherwise.

◆ SetLinger()

virtual bool FSocket::SetLinger ( bool  bShouldLinger = true,
int32  Timeout = 0 
)
pure virtual

Sets whether and how long a socket will linger after closing.

参数
bShouldLingerWhether to have the socket remain open for a time period after closing or not.
TimeoutThe amount of time to linger before closing.
返回
true if the call succeeded, false otherwise.

◆ SetMulticastInterface()

virtual bool FSocket::SetMulticastInterface ( const FInternetAddr &  InterfaceAddress)
pure virtual

Sets the interface used to send outgoing multicast datagrams.

Multicast traffic is sent using the default interface, this allows to explicitly set the interface used to send outgoing multicast datagrams.

参数
InterfaceAddressThe interface address.
返回
true if the call succeeded, false otherwise.

◆ SetMulticastLoopback()

virtual bool FSocket::SetMulticastLoopback ( bool  bLoopback)
pure virtual

Enables or disables multicast loopback on the socket (UDP only).

This setting determines whether multicast datagrams are looped back to the sending socket. By default, multicast loopback is enabled. It must be enabled if more than one listener is present on a host.

参数
bLoopbackWhether loopback should be enabled.
参见
LeaveMulticastGroup, JoinMulticastGroup, SetMulticastTtl

◆ SetMulticastTtl()

virtual bool FSocket::SetMulticastTtl ( uint8  TimeToLive)
pure virtual

Sets the time to live (TTL) for multicast datagrams.

The default TTL for multicast datagrams is 1, which prevents them from being forwarded beyond the local subnet. Higher values will allow multicast datagrams to be sent into neighboring subnets, if multicast capable routers are present.

参数
TimeToLiveNumber of hops the datagram can make.
参见
LeaveMulticastGroup, JoinMulticastGroup, SetMulticastLoopback

◆ SetNoDelay()

virtual bool FSocket::SetNoDelay ( bool  bIsNoDelay = true)
pure virtual

Sets this socket into TCP_NODELAY mode (TCP only).

参数
bIsNoDelayWhether to enable no delay mode.
返回
true if successful, false otherwise.

◆ SetNonBlocking()

virtual bool FSocket::SetNonBlocking ( bool  bIsNonBlocking = true)
pure virtual

Sets this socket into non-blocking mode.

参数
bIsNonBlockingWhether to enable blocking or not.
返回
true if successful, false otherwise.

◆ SetReceiveBufferSize()

virtual bool FSocket::SetReceiveBufferSize ( int32  Size,
int32 &  NewSize 
)
pure virtual

Sets the size of the receive buffer to use.

参数
SizeThe size to change it to.
NewSizeWill contain the size that was set (in case OS can't set that).
返回
true if the call succeeded, false otherwise.

◆ SetRecvErr()

virtual bool FSocket::SetRecvErr ( bool  bUseErrorQueue = true)
pure virtual

Enables error queue support for the socket.

参数
bUseErrorQueueWhether to enable error queuing or not.
返回
true if the call succeeded, false otherwise.

◆ SetRetrieveTimestamp()

virtual bool FSocket::SetRetrieveTimestamp ( bool  bRetrieveTimestamp = true)
virtual

Sets whether to retrieve the system-level receive timestamp, for sockets

参数
bRetrieveTimestampWhether to retrieve the timestamp upon receive
返回
True if the call succeeded, false otherwise.

◆ SetReuseAddr()

virtual bool FSocket::SetReuseAddr ( bool  bAllowReuse = true)
pure virtual

Sets whether a socket can be bound to an address in use.

参数
bAllowReuseWhether to allow reuse or not.
返回
true if the call succeeded, false otherwise.

◆ SetSendBufferSize()

virtual bool FSocket::SetSendBufferSize ( int32  Size,
int32 &  NewSize 
)
pure virtual

Sets the size of the send buffer to use.

参数
SizeThe size to change it to.
NewSizeWill contain the size that was set (in case OS can't set that).
返回
true if the call succeeded, false otherwise.

◆ Shutdown()

virtual bool FSocket::Shutdown ( ESocketShutdownMode  Mode)
pure virtual

Shuts down the socket, making it unusable for reads and/or writes.

This does not close the socket!

参数
Types
返回
true if successful, false otherwise.

◆ Wait()

virtual bool FSocket::Wait ( ESocketWaitConditions::Type  Condition,
FTimespan  WaitTime 
)
pure virtual

Blocks until the specified condition is met.

参数
ConditionThe condition to wait for.
WaitTimeThe maximum time to wait.
返回
true if the condition was met, false if the time limit expired or an error occurred.

◆ WaitForPendingConnection()

virtual bool FSocket::WaitForPendingConnection ( bool &  bHasPendingConnection,
const FTimespan &  WaitTime 
)
pure virtual

Waits for a pending connection on the socket.

参数
outbHasPendingConnection Will indicate whether a connection is pending or not.
WaitTimeThe maximum time to wait for a connection. If zero, the function will not wait and will return immediately with a value in bHasPendingConnection.
返回
true if successful, false otherwise.

该类的文档由以下文件生成: