The base class for MISOCKET_TCP and MISOCKET_LOCAL The base class does not have Open or Close methods. More...
#include <mi32/socket.h>

Classes | |
| struct | ADDR |
| A generic socket address. More... | |
| class | CLIENT |
| Base class for any client that wants to be notified of a socket's state. More... | |
| struct | IPADDR |
| An Internet Protocol address. More... | |
Public Types | |
| enum | FAMILY { FAMILY_NONE = 0, FAMILY_LOCAL = 1, FAMILY_INET = 2 } |
| enum | TYPE { TYPE_NONE = 0, TYPE_STREAM = 1, TYPE_DGRAM = 2 } |
Public Member Functions | |
| MISOCKET () | |
| virtual | ~MISOCKET () |
| MISOCKET * | Accept (ADDR &address) |
| ERRVALUE | Bind (const ADDR &address) |
| ERRVALUE | Connect (const ADDR &address) |
| void | GetAddress (MISTRING &mistr, bool bDoReverseDNSLookup=false) const |
| const ADDR & | GetAddress () const |
| bool | GetSockName (ADDR &addr) const |
| int | GetTimeOut () const |
| bool | IsNonBlocking () const |
| ERRVALUE | Listen () |
| ERRVALUE | ReadStr (STRUTF8 &string) |
| void | SetNonBlocking (bool bNonBlocking=true) |
| void | SetTimeOut (int seconds) |
| ERRVALUE | Socket (FAMILY family, TYPE type=TYPE_STREAM) |
| ERRVALUE | WriteStr (const char *str) |
The base class for MISOCKET_TCP and MISOCKET_LOCAL The base class does not have Open or Close methods.
Bind and are implemented in the derived classes, as each implementation may take different parameters. You close a socket by deleting the class instance.
| enum MISOCKET::FAMILY |
| enum MISOCKET::TYPE |
| MISOCKET::MISOCKET | ( | ) |
Default constructor.
| virtual MISOCKET::~MISOCKET | ( | ) | [virtual] |
Destructor.
If this socket has a CLIENT bound to it, the client will be reset to a NULL socket.
Accept an incoming connection.
The socket must be in a listening state. If the socket is non-blocking and has a CLIENT attached to it, then this function will always return 0 and the client's OnAccept() will be called when an incoming connection is available Creates and returns a new socket for the connection. The address returned tells you where the incoming connection is from. It is up to the caller to delete the MISOCKET returned when done.
| address | Address of incoming connection (returned) |
Bind the socket to a given address This is done if you plan to make the socket into a listening socket or if you want all outgoing connections ton this socket to come from as specific address or port.
Connect to a given server If the socket is non-blocking, Connect may return before the connection is actually made.
In this case, a CLIENT attached to the socket will have its OnConnect() called when the connection completes or OnTimeOut if it doesn't complete.
| void MISOCKET::GetAddress | ( | MISTRING & | mistr, | |
| bool | bDoReverseDNSLookup = false | |||
| ) | const |
Returns the address of the socket in a humanly-readable form.
| mistr | The string to place the address in | |
| bDoReverseDNSLookup | If true, IP sockets will use reverse DNS to find the hostname of the address. If false, it will just return the numeric IP address. Ignored for non-IP sockets. |
| const ADDR& MISOCKET::GetAddress | ( | ) | const |
Returns the MISOCKET::ADDR of the socket.
If not bound to any address, the returned address will be unitialized and will have a family of FAMILY_NONE
| bool MISOCKET::GetSockName | ( | ADDR & | addr | ) | const |
Gets the address of local end of a connected socket.
This is useful on a multi-homed server to find out which interface you're connected through.
| int MISOCKET::GetTimeOut | ( | ) | const |
Get the timeout interval in seconds.
| bool MISOCKET::IsNonBlocking | ( | ) | const |
Determine if the socket is nonblocking.
| ERRVALUE MISOCKET::Listen | ( | ) |
Put the socket into listening mode.
Must be previously Bound
Read a single new-line terminated string (stripping out the newline).
If there is no newline in the currently available input buffer this function will either wait for one or return false if the socket is non-blocking. Note: This function assumes that the incoming data is utf-8
| void MISOCKET::SetNonBlocking | ( | bool | bNonBlocking = true |
) |
Set the socket to non-blocking mode.
In non-blocking mode, if a read request cannot be fulfilled with what's currently available, it will return 0 and not read anything.
| void MISOCKET::SetTimeOut | ( | int | seconds | ) |
Set the timeout for I/O operations.
To disable timeouts, set it to 0.
Allocates a new socket of a given family and type.
| family | Socket family | |
| type | Socket type (default is STREAM) |
| ERRVALUE MISOCKET::WriteStr | ( | const char * | str | ) |
Write a NULL-terminated string.
1.6.1