TNL::Socket class Reference
TNL::Socket Class Reference
#include <tnlUDP.h>
Detailed Description
The
Socket class encapsulates a platform's network socket.
|
Public Types |
| enum | { DefaultBufferSize = 32768
} |
Public Member Functions |
| | Socket (const Address &bindAddress, U32 sendBufferSize=DefaultBufferSize, U32 recvBufferSize=DefaultBufferSize, bool acceptsBroadcast=true, bool nonblockingIO=true) |
| | Opens a socket on the specified address/port.
|
| | ~Socket () |
| | Closes the socket.
|
| bool | isValid () |
| | Returns true if the socket was created successfully.
|
| NetError | sendto (const Address &address, const U8 *buffer, S32 bufferSize) |
| | Sends a packet to the address through sourceSocket.
|
| NetError | recvfrom (Address *address, U8 *buffer, S32 bufferSize, S32 *bytesRead) |
| | Read an incoming packet.
|
| Address | getBoundAddress () |
| | Returns the Address corresponding to this socket, as bound on the local machine.
|
| NetError | connect (const Address &theAddress) |
| NetError | recv (U8 *buffer, S32 bufferSize, S32 *bytesRead) |
| NetError | send (const U8 *buffer, S32 bufferSize) |
Static Public Member Functions |
| void | getInterfaceAddresses (Vector< Address > *addressVector) |
| | Returns the list of network addresses this host can be bound to.
|
Private Attributes |
| S32 | mPlatformSocket |
| | The OS-level socket.
|
| U32 | mTransportProtocol |
| | The transport type this socket uses.
|
Member Enumeration Documentation
|
|
- Enumeration values:
-
| DefaultBufferSize |
The default send and receive buffer sizes. |
|
Constructor & Destructor Documentation
| TNL::Socket::Socket |
( |
const Address & |
bindAddress, |
|
|
U32 |
sendBufferSize = DefaultBufferSize, |
|
|
U32 |
recvBufferSize = DefaultBufferSize, |
|
|
bool |
acceptsBroadcast = true, |
|
|
bool |
nonblockingIO = true |
|
) |
|
|
|
|
Opens a socket on the specified address/port.
A connectPort of 0 will bind to any available port. Passing a valid address for ipBindInterface will attempt to bind this socket to a particular IP address on the local machine. |
Member Function Documentation
| bool TNL::Socket::isValid |
( |
|
) |
|
|
|
|
Returns true if the socket was created successfully.
|
|
|
Sends a packet to the address through sourceSocket.
|
|
|
Read an incoming packet.
- Parameters:
-
| address | Address originating the packet. |
| buffer | Buffer in to which to read the packet. |
| bufferSize | Size of the buffer (this prevents buffer overflows!). |
| bytesRead | Specifies the number of bytes which were actually in the packet. |
|
| Address TNL::Socket::getBoundAddress |
( |
|
) |
|
|
|
|
Returns the Address corresponding to this socket, as bound on the local machine.
|
| void TNL::Socket::getInterfaceAddresses |
( |
Vector< Address > * |
addressVector |
) |
[static] |
|
|
|
Returns the list of network addresses this host can be bound to.
Currently this only returns IP addresses, with the port field set to 0. |
Field Documentation
|
|
The transport type this socket uses.
|