|
|
 |
 |
|
TCP/IP or UDP socket utility functions
|
Defines |
|
#define | OSIPADDR_ANY ((OSIPADDR)0) |
|
#define | OSIPADDR_LOCAL ((OSIPADDR)0x7f000001UL) |
Typedefs |
| typedef unsigned long | OSIPADDR |
| | The IP address represented as unsigned long value.
|
Functions |
| int | rtxSocketAccept (OSRTSOCKET socket, OSRTSOCKET *pNewSocket, OSIPADDR *destAddr, int *destPort) |
| | This function permits an incoming connection attempt on a socket.
|
| int | rtxSocketAddrToStr (OSIPADDR ipAddr, char *pbuf, size_t bufsize) |
| | This function converts an IP address to its string representation.
|
| int | rtxSocketBind (OSRTSOCKET socket, OSIPADDR addr, int port) |
| | This function associates a local address with a socket.
|
| int | rtxSocketClose (OSRTSOCKET socket) |
| | This function closes an existing socket.
|
| int | rtxSocketConnect (OSRTSOCKET socket, const char *host, int port) |
| | This function establishes a connection to a specified socket.
|
| int | rtxSocketCreate (OSRTSOCKET *psocket) |
| | This function creates a socket.
|
| int | rtxSocketGetHost (const char *host, struct in_addr *inaddr) |
| | This function resolves the given host name to an IP address.
|
| int | rtxSocketsInit () |
| | This function initiates use of sockets by an application.
|
| int | rtxSocketListen (OSRTSOCKET socket, int maxConnection) |
| | This function places a socket a state where it is listening for an incoming connection.
|
| int | rtxSocketRecv (OSRTSOCKET socket, OSOCTET *pbuf, int bufsize) |
| | This function receives data from a connected socket.
|
| int | rtxSocketSend (OSRTSOCKET socket, const OSOCTET *pdata, int size) |
| | This function sends data on a connected socket.
|
| int | rtxSocketStrToAddr (const char *pIPAddrStr, OSIPADDR *pIPAddr) |
| | This function converts the string with IP address to a double word representation.
|
Typedef Documentation
|
|
The IP address represented as unsigned long value.
The most significant 8 bits in this unsigned long value represent the first number of the IP address. The least significant 8 bits represent the last number of the IP address.
Definition at line 56 of file rtxSocket.h. |
Function Documentation
|
|
This function permits an incoming connection attempt on a socket.
It extracts the first connection on the queue of pending connections on socket. It then creates a new socket and returns a handle to the new socket. The newly created socket is the socket that will handle the actual connection and has the same properties as original socket. See description of 'accept' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate function. |
| pNewSocket | The pointer to variable to receive the new socket's handle. |
| destAddr | Optional pointer to a buffer that receives the IP address of the connecting entity. It may be NULL. |
| destPort | Optional pointer to a buffer that receives the port of the connecting entity. It may be NULL. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
| int rtxSocketAddrToStr |
( |
OSIPADDR |
ipAddr, |
|
|
char * |
pbuf, |
|
|
size_t |
bufsize |
|
) |
|
|
|
|
This function converts an IP address to its string representation.
- Parameters:
-
| ipAddr | The IP address to be converted. |
| pbuf | Pointer to the buffer to receive a string with the IP address. |
| bufsize | Size of the buffer. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
|
This function associates a local address with a socket.
It is used on an unconnected socket before subsequent calls to the rtxSocketConnect or rtxSocketListen functions. See description of 'bind' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate function. |
| addr | The local IP address to assign to the socket. |
| port | The local port number to assign to the socket. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
|
This function closes an existing socket.
- Parameters:
-
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
| int rtxSocketConnect |
( |
OSRTSOCKET |
socket, |
|
|
const char * |
host, |
|
|
int |
port |
|
) |
|
|
|
|
This function establishes a connection to a specified 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. See description of 'connect' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate function. |
| host | The null-terminated string with the IP address in the following format: "NNN.NNN.NNN.NNN", where NNN is a number in the range (0..255). |
| port | The destination port to connect. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
|
This function creates a socket.
The only streaming TCP/IP sockets are supported at the moment.
- Parameters:
-
| psocket | The pointer to the socket's handle variable to receive the handle of new socket. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
| int rtxSocketGetHost |
( |
const char * |
host, |
|
|
struct in_addr * |
inaddr |
|
) |
|
|
|
|
This function resolves the given host name to an IP address.
The reulsting address is stored in the given socket address structure.
- Parameters:
-
| host | Host name to resolve |
| inaddr | Socket address structure to receive resolved IP address |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
| int rtxSocketListen |
( |
OSRTSOCKET |
socket, |
|
|
int |
maxConnection |
|
) |
|
|
|
|
This function places a socket a state where it is listening for an incoming connection.
To accept connections, a socket is first created with the rtxSocketCreate function and bound to a local address with the rtxSocketBind function, a maxConnection for incoming connections is specified with rtxSocketListen, and then the connections are accepted with the rtxSocketAccept function. See description of 'listen' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate function. |
| maxConnection | Maximum length of the queue of pending connections. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
|
This function receives data from a connected socket.
It is used to read incoming data on sockets. The socket must be connected before calling this function. See description of 'recv' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate or rtxSocketAccept function. |
| pbuf | Pointer to the buffer for the incoming data. |
| bufsize | Length of the buffer. |
- Returns:
- If no error occurs, returns the number of bytes received. Otherwise, the negative value is error code.
|
|
|
This function sends data on a connected socket.
It is used to write outgoing data on a connected socket. See description of 'send' socket function for further details.
- Parameters:
-
| socket | The socket's handle created by call to rtxSocketCreate or rtxSocketAccept function. |
| pdata | Buffer containing the data to be transmitted. |
| size | Length of the data in pdata. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
|
This function initiates use of sockets by an application.
This function must be called first before use sockets.
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
| int rtxSocketStrToAddr |
( |
const char * |
pIPAddrStr, |
|
|
OSIPADDR * |
pIPAddr |
|
) |
|
|
|
|
This function converts the string with IP address to a double word representation.
The converted address may be used with the rtxSocketBind function.
- Parameters:
-
| pIPAddrStr | The null-terminated string with the IP address in the following format: "NNN.NNN.NNN.NNN", where NNN is a number in the range (0..255). |
| pIPAddr | Pointer to the converted IP address. |
- Returns:
- Completion status of operation: 0 (0) = success, negative return value is error.
|
|
This file was last modified on
8 Jan 2007. XBinder, Version 1.1.9 |