Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# OsclTCPSocket Class Reference
[OSCL IO]

`#include <oscl_socket.h>`

Inheritance diagram for OsclTCPSocket:

## Public Methods
OSCL_IMPORT_REF | ~OsclTCPSocket ()
OSCL_IMPORT_REF TPVSocketEvent | ThreadLogoff ()
OSCL_IMPORT_REF TPVSocketEvent | ThreadLogon (OsclSocketServ &aServ, OsclSocketObserver *aObserver)
OSCL_IMPORT_REF int32 | Close ()
OSCL_IMPORT_REF int32 | Bind (OsclNetworkAddress &aAddress)
OSCL_IMPORT_REF TPVSocketEvent | BindAsync (OsclNetworkAddress &aAddress, int32 aTimeoutMsec=(-1))
OSCL_IMPORT_REF void | CancelBind ()
OSCL_IMPORT_REF int32 | SetOptionToReuseAddress ()
OSCL_IMPORT_REF int32 | SetTOS (const OsclSocketTOS &aTOS)
OSCL_IMPORT_REF int32 | GetPeerName (OsclNetworkAddress &aPeerName)
OSCL_IMPORT_REF int32 | Listen (int32 aQueueSize)
OSCL_IMPORT_REF TPVSocketEvent | ListenAsync (int32 aQueueSize, int32 aTimeoutMsec=(-1))
OSCL_IMPORT_REF void | CancelListen ()
OSCL_IMPORT_REF OsclTCPSocket * | GetAcceptedSocketL (uint32 aId)
OSCL_IMPORT_REF uint8 * | GetRecvData (int32 *aLength)
OSCL_IMPORT_REF uint8 * | GetSendData (int32 *aLength)
OSCL_IMPORT_REF TPVSocketEvent | Connect (OsclNetworkAddress &aAddress, int32 aTimeoutMsec=-1)
OSCL_IMPORT_REF void | CancelConnect ()
OSCL_IMPORT_REF TPVSocketEvent | Shutdown (TPVSocketShutdown aHow, int32 aTimeoutMsec=-1)
OSCL_IMPORT_REF void | CancelShutdown ()
OSCL_IMPORT_REF TPVSocketEvent | Accept (int32 aTimeout=-1)
OSCL_IMPORT_REF void | CancelAccept ()
OSCL_IMPORT_REF TPVSocketEvent | Send (const uint8 *aPtr, uint32 aLen, int32 aTimeoutMsec=-1)
OSCL_IMPORT_REF void | CancelSend ()
OSCL_IMPORT_REF TPVSocketEvent | Recv (uint8 *aPtr, uint32 aMaxLen, int32 aTimeoutMsec=-1)
OSCL_IMPORT_REF void | CancelRecv ()
## Static Public Methods
OSCL_IMPORT_REF OsclTCPSocket * | NewL (Oscl_DefAlloc &alloc, OsclSocketServ &aServ, OsclSocketObserver *aObserver, uint32 aId)

## Detailed Description

The TCP Socket class

## Constructor & Destructor Documentation

OSCL_IMPORT_REF OsclTCPSocket::~OsclTCPSocket | ( |  | ) |

| Destructor. The object must be deleted using the same allocator used in the NewL call.

## Member Function Documentation

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::Accept | ( | int32 | aTimeout = -1 | ) |

  | Accept incoming connections. This is an asynchronous method. Parameters:
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF int32 OsclTCPSocket::Bind | ( | OsclNetworkAddress & | aAddress | ) |

  | Bind a TCP socket to an address. This is a synchronous method. Parameters:
  aAddress: | Bind address.
Returns: Returns OsclErrNone for success, or a platform-specific error code.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::BindAsync | ( | OsclNetworkAddress & | aAddress,
|  | int32 | aTimeoutMsec = (-1)
| ) |

  | Bind a TCP socket to an address. This is an asynchronous method. Parameters:
  aAddress: | Bind address.
  aTimeoutMsec: | Optional timeout. Use a negative value for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF void OsclTCPSocket::CancelAccept | ( |  | ) |

| Cancel Accept This method will cancel any pending Accept operation on the current socket, causing the Accept to complete with error EPVSocketCancel. If there is no pending Accept operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelBind | ( |  | ) |

| Cancel Bind This method will cancel any pending BindAsync operation on the current socket, causing the BindAsync to complete with error EPVSocketCancel. If there is no pending BindAsync operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelConnect | ( |  | ) |

| Cancel Connect This method will cancel any pending Connect operation on the current socket, causing the Connect to complete with error EPVSocketCancel. If there is no pending Connect operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelListen | ( |  | ) |

| Cancel Async Listen This method will cancel any pending ListenAsync operation on the current socket, causing the Listen to complete with error EPVSocketCancel. If there is no pending Listen operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelRecv | ( |  | ) |

| Cancel Recv This method will cancel any pending Recv operation on the current socket, causing the Recv to complete with error EPVSocketCancel. If there is no pending Recv operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelSend | ( |  | ) |

| Cancel Send This method will cancel any pending Send operation on the current socket, causing the Send to complete with error EPVSocketCancel. If there is no pending Send operation, this method will have no effect.

OSCL_IMPORT_REF void OsclTCPSocket::CancelShutdown | ( |  | ) |

| Cancel Shutdown This method will cancel any pending Shutdown operation on the current socket, causing the Shutdown to complete with error EPVSocketCancel. If there is no pending Shutdown operation, this method will have no effect.

OSCL_IMPORT_REF int32 OsclTCPSocket::Close | ( |  | ) |

| Close a TCP socket. This is a synchronous method. Once it is closed a socket cannot be re-opened. Sockets are automatically closed when they are deleted. This method may be used to see any error code returned from the platform's socket close call. Returns: Returns OsclErrNone for success, or a platform-specific error code.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::Connect | ( | OsclNetworkAddress & | aAddress,
|  | int32 | aTimeoutMsec = -1
| ) |

  | Connect to an address. This is an asynchronous method. Parameters:
  aAddress: | a network address.
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF OsclTCPSocket* OsclTCPSocket::GetAcceptedSocketL | ( | uint32 | aId | ) |

  | Retrieve the accept socket after a successful Accept operation. This is a synchronous method. Parameters:
  aId: | Socket ID. The caller must assign an ID to each socket. The ID is used to identify the socket in observer callbacks.
Returns: Returns pointer to socket, or NULL if error. Note: The caller is reponsible for deleting any accepted socket that it retrieves.

OSCL_IMPORT_REF int32 OsclTCPSocket::GetPeerName | ( | OsclNetworkAddress & | aPeerName | ) |

  | Retrieves the peer address of the socket Parameters:
  aPeerName: | This will store the peer address when API returns successfully.
Returns: Returns OsclErrNone for success, or a platform-specific error code. or PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL for the underlying OS

OSCL_IMPORT_REF uint8* OsclTCPSocket::GetRecvData | ( | int32 * | aLength | ) |

  | Retrieve the received data after a successful Recv operation. This is a synchronous method. Parameters:
  aLength: | (output) number of bytes of data received.
Returns: Returns pointer to received data, or NULL if none.

OSCL_IMPORT_REF uint8* OsclTCPSocket::GetSendData | ( | int32 * | aLength | ) |

  | Retrieve the sent data after a successful Send operation. This is a synchronous method. Parameters:
  aLength: | (output) number of bytes of data sent.
Returns: Returns pointer to sent data, or NULL if none.

OSCL_IMPORT_REF int32 OsclTCPSocket::Listen | ( | int32 | aQueueSize | ) |

  | Listen. This is a synchronous method. Parameters:
  aQueueSize: | Queue size.
Returns: Returns OsclErrNone for success, or a platform-specific error code.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::ListenAsync | ( | int32 | aQueueSize,
|  | int32 | aTimeoutMsec = (-1)
| ) |

  | ListenAsync This is an asynchronous method. Parameters:
  aQueueSize: | Queue size.
  aTimeoutMsec: | Optional timeout. Use a negative value for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF OsclTCPSocket* OsclTCPSocket::NewL | ( | Oscl_DefAlloc & | alloc,
|  | OsclSocketServ & | aServ,
|  | OsclSocketObserver * | aObserver,
|  | uint32 | aId
| ) | `[static]`

  | Create a TCP Socket. May leave if failure. Parameters:
  alloc: | Memory allocator.
  aServ: | Socket server. Must be connected.
  aObserver: | Socket observer.
  aId: | Socket ID. The caller must assign an ID to each socket. The ID is used to identify the socket in observer callbacks.
Returns: Returns pointer to socket.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::Recv | ( | uint8 * | aPtr,
|  | uint32 | aMaxLen,
|  | int32 | aTimeoutMsec = -1
| ) |

  | Receive Data. This is an asynchronous method. Parameters:
  aPtr: | Buffer for received data.
  aMaxLen: | Length of buffer.
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::Send | ( | const uint8 * | aPtr,
|  | uint32 | aLen,
|  | int32 | aTimeoutMsec = -1
| ) |

  | Send Data. This is an asynchronous method. Parameters:
  aPtr: | Data to send.
  aLen: | Length of data to send.
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF int32 OsclTCPSocket::SetOptionToReuseAddress | ( |  | ) |

| Allows the server to bind to an address which is in a TIME_WAIT state. Returns: Returns: OsclErrNone for success, or a platform-specific error code. or PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining multicast group PVSOCK_ERR_BAD_PARAM, if config io file is not configured in accordance with underlying OS PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL for the underlying OS

OSCL_IMPORT_REF int32 OsclTCPSocket::SetTOS | ( | const OsclSocketTOS & | aTOS | ) |

  | Sets the Type of Service field of each outgoing IP datagram. Parameters:
  aTOS: | Specifies the type of service requested.
Returns: Returns: OsclErrNone for success, or a platform-specific error code. or PVSOCK_ERR_NOT_SUPPORTED, if underlying OS doesn't support joining multicast group PVSOCK_ERR_BAD_PARAM, if config io file is not configured in accordance with underlying OS PVSOCK_ERR_NOT_IMPLEMENTED, if this API is not implemented in OSCL for the underlying OS

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::Shutdown | ( | TPVSocketShutdown | aHow,
|  | int32 | aTimeoutMsec = -1
| ) |

  | Shutdown a socket. This is an asynchronous method. Parameters:
  aHow: | type of shutdown
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
Returns: Will return EPVSocketPending if successful. When the operation is complete, a callback to the observer will occur with the completion status. If the operation cannot be initiated, the call will return EPVSocketFailure and there will be no callback.

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::ThreadLogoff | ( |  | ) |

| Thread logoff routine. This will prepare for transfer and use of the socket in another thread. All socket requests must be complete prior to calling this routine. If any requests are still active, it will return EPVSocketFailure;

OSCL_IMPORT_REF TPVSocketEvent OsclTCPSocket::ThreadLogon | ( | OsclSocketServ & | aServ,
|  | OsclSocketObserver * | aObserver
| ) |

| Thread logon routine. This will complete the transfer of a socket from another thread for use in the current thread. The ThreadLogoff API must be called in the original thread prior to calling ThreadLogon.

The documentation for this class was generated from the following file:

- oscl_socket.h