OSRTSocket Class Reference
[TCP/IP or UDP Socket Classes]
Wrapper class for TCP/IP or UDP sockets.
More...
#include <OSRTSocket.h>
Public Member Functions | |
| EXTRTMETHOD | OSRTSocket () |
| This is the default constructor. | |
| EXTRTMETHOD | OSRTSocket (OSRTSOCKET socket, OSBOOL ownership=FALSE) |
| This constructor initializes an instance by using an existing socket. | |
| EXTRTMETHOD | OSRTSocket (const OSRTSocket &socket) |
| The copy constructor. | |
| EXTRTMETHOD | ~OSRTSocket () |
| The destructor. | |
| EXTRTMETHOD OSRTSocket * | accept (OSIPADDR *destIP=0, int *port=0) |
| This method permits an incoming connection attempt on a socket. | |
| EXTRTMETHOD int | bind (OSIPADDR addr, int port) |
| This method associates a local address with a socket. | |
| EXTRTMETHOD int | bind (const char *pAddrStr, int port) |
| This method associates a local address with a socket. | |
| int | bind (int port) |
| This method associates only a local port with a socket. | |
| EXTRTMETHOD int | blockingRead (OSOCTET *pbuf, size_t readBytes) |
| This method receives data from the connected socket. | |
| EXTRTMETHOD int | close () |
| This method closes this socket. | |
| EXTRTMETHOD int | connect (const char *host, int port) |
| This method establishes a connection to this socket. | |
| OSBOOL | getOwnership () |
| Returns the ownership of underlying O/S socket. | |
| OSRTSOCKET | getSocket () const |
| This method returns the handle of the socket. | |
| int | getStatus () |
| Returns a completion status of last operation. | |
| EXTRTMETHOD int | listen (int maxConnections) |
| This method places a socket into a state where it is listening for an incoming connection. | |
| EXTRTMETHOD int | recv (OSOCTET *pbuf, OSUINT32 bufsize) |
| This method receives data from a connected socket. | |
| void | setOwnership (OSBOOL ownership) |
| Transfers an ownership of the underlying O/S socket to or from the socket object. | |
| EXTRTMETHOD int | send (const OSOCTET *pdata, OSUINT32 size) |
| This method sends data on a connected socket. | |
Static Public Member Functions | |
| static EXTRTMETHOD const char * | addrToString (OSIPADDR ipAddr, char *pAddrStr, int bufsize) |
| This method converts an IP address to its string representation. | |
| static EXTRTMETHOD OSIPADDR | stringToAddr (const char *pAddrStr) |
| This method converts a string containing an Internet Protocol dotted address into a proper OSIPADDR address. | |
Protected Member Functions | |
| OSBOOL | isInitialized () |
Protected Attributes | |
| OSRTSOCKET | mSocket |
| handle of the socket | |
| int | mInitStatus |
| int | mStatus |
| OSBOOL | mOwner |
| indicates this class owns the socket | |
Detailed Description
Wrapper class for TCP/IP or UDP sockets.
Definition at line 48 of file OSRTSocket.h.
Constructor & Destructor Documentation
|
|
This is the default constructor. It initializes all internal members with default values and creates a new socket structure. Use getStatus() method to determine has error occurred during the initialization or not. |
|
||||||||||||
|
This constructor initializes an instance by using an existing socket.
|
|
|
The copy constructor. The copied instance will have the same socket handle as the original one, but will not be the owner of the handle. |
|
|
The destructor. This closes socket if the instance is the owner of the socket. |
Member Function Documentation
|
||||||||||||
|
This method permits an incoming connection attempt on a socket. It extracts the first connection on the queue of pending connections on the socket. It then creates a new socket and returns an instance of the new socket. The newly created socket will handle the actual connection and has the same properties as the original socket.
|
|
||||||||||||||||
|
This method converts an IP address to its string representation.
|
|
|
This method associates only a local port with a socket. It is used on an unconnected socket before subsequent calls to the OSRTSocket::connect or OSRTSocket::listen methods.
Definition at line 168 of file OSRTSocket.h. |
|
||||||||||||
|
This method associates a local address with a socket. It is used on an unconnected socket before subsequent calls to the connect or listen methods.
|
|
||||||||||||
|
This method associates a local address with a socket. It is used on an unconnected socket before subsequent calls to the connect or listen methods.
|
|
||||||||||||
|
This method receives data from the connected socket. In this case, the connection is blocked until either the requested number of bytes is received or the socket is closed or an error occurs.
|
|
|
This method closes this socket.
|
|
||||||||||||
|
This method establishes a connection to this socket. It is used to create a connection to the specified destination. When the socket call completes successfully, the socket is ready to send and receive data.
|
|
|
Returns the ownership of underlying O/S socket.
Definition at line 218 of file OSRTSocket.h. |
|
|
This method returns the handle of the socket.
Definition at line 225 of file OSRTSocket.h. |
|
|
Returns a completion status of last operation.
Definition at line 234 of file OSRTSocket.h. |
|
|
This method places a socket into a state where it is listening for an incoming connection.
|
|
||||||||||||
|
This method receives data from a connected socket. It is used to read incoming data on sockets. The socket must be connected before calling this function.
|
|
||||||||||||
|
This method sends data on a connected socket. It is used to write outgoing data on a connected socket.
|
|
|
Transfers an ownership of the underlying O/S socket to or from the socket object. If the socket object has the ownership of the underlying O/S socket it will close the O/S socket when the socket object is being closed or destroyed.
Definition at line 273 of file OSRTSocket.h. |
|
|
This method converts a string containing an Internet Protocol dotted address into a proper OSIPADDR address.
|
The documentation for this class was generated from the following file:
