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

# OsclUDPSocket Class Reference
[OSCL IO]

`#include <oscl_socket.h>`

Inheritance diagram for OsclUDPSocket:

## Public Methods
OSCL_IMPORT_REF | ~OsclUDPSocket ()
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 int32 | Join (OsclNetworkAddress &aAddress)
OSCL_IMPORT_REF int32 | JoinMulticastGroup (OsclIpMReq &aMReq)
OSCL_IMPORT_REF int32 | SetMulticastTTL (int32 aTTL)
OSCL_IMPORT_REF int32 | SetOptionToReuseAddress ()
OSCL_IMPORT_REF int32 | SetTOS (const OsclSocketTOS &aTOS)
OSCL_IMPORT_REF int32 | GetPeerName (OsclNetworkAddress &aPeerName)
OSCL_IMPORT_REF TPVSocketEvent | BindAsync (OsclNetworkAddress &aAddress, int32 aTimeoutMsec=(-1))
OSCL_IMPORT_REF void | CancelBind ()
OSCL_IMPORT_REF uint8 * | GetRecvData (int32 *aLength)
OSCL_IMPORT_REF uint8 * | GetSendData (int32 *aLength)
OSCL_IMPORT_REF TPVSocketEvent | SendTo (const uint8 *aPtr, uint32 aLen, OsclNetworkAddress &aAddress, int32 aTimeoutMsec=-1)
OSCL_IMPORT_REF void | CancelSendTo ()
OSCL_IMPORT_REF TPVSocketEvent | RecvFrom (uint8 *aPtr, uint32 aMaxLen, OsclNetworkAddress &aAddress, int32 aTimeoutMsec=-1, uint32 aMultiRecvLimit=0, Oscl_Vector< uint32, OsclMemAllocator > *aPacketLen=NULL, Oscl_Vector< OsclNetworkAddress, OsclMemAllocator > *aPacketSource=NULL)
OSCL_IMPORT_REF void | CancelRecvFrom ()
OSCL_IMPORT_REF int32 | SetRecvBufferSize (uint32 size)
## Static Public Methods
OSCL_IMPORT_REF OsclUDPSocket * | NewL (Oscl_DefAlloc &alloc, OsclSocketServ &aServ, OsclSocketObserver *aObserver, uint32 aId)

## Detailed Description

The UDP Socket class

## Constructor & Destructor Documentation

OSCL_IMPORT_REF OsclUDPSocket::~OsclUDPSocket | ( |  | ) |

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

## Member Function Documentation

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

  | Bind a UDP 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 OsclUDPSocket::BindAsync | ( | OsclNetworkAddress & | aAddress,
|  | int32 | aTimeoutMsec = (-1)
| ) |

  | Bind a UDP 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 OsclUDPSocket::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 OsclUDPSocket::CancelRecvFrom | ( |  | ) |

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

OSCL_IMPORT_REF void OsclUDPSocket::CancelSendTo | ( |  | ) |

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

OSCL_IMPORT_REF int32 OsclUDPSocket::Close | ( |  | ) |

| Close a UDP 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 int32 OsclUDPSocket::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* OsclUDPSocket::GetRecvData | ( | int32 * | aLength | ) |

  | Retrieve the received data after a successful RecvFrom 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* OsclUDPSocket::GetSendData | ( | int32 * | aLength | ) |

  | Retrieve the sent data after a successful SendTo 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 OsclUDPSocket::Join | ( | OsclNetworkAddress & | aAddress | ) |

  | Bind a UDP socket to an address and Join the multicast group. This is a synchronous method. Parameters:
  aAddress: | Bind address.
Returns: Returns OsclErrNone for success, or a platform-specific error code. May throw an OsclErrNotSupported Exception

OSCL_IMPORT_REF int32 OsclUDPSocket::JoinMulticastGroup | ( | OsclIpMReq & | aMReq | ) |

  | Join the multicast group. Parameters:
  aMReq: | Multicast group information.
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 OsclUDPSocket* OsclUDPSocket::NewL | ( | Oscl_DefAlloc & | alloc,
|  | OsclSocketServ & | aServ,
|  | OsclSocketObserver * | aObserver,
|  | uint32 | aId
| ) | `[static]`

  | Create a UDP 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 OsclUDPSocket::RecvFrom | ( | uint8 * | aPtr,
|  | uint32 | aMaxLen,
|  | OsclNetworkAddress & | aAddress,
|  | int32 | aTimeoutMsec = -1,
|  | uint32 | aMultiRecvLimit = 0,
|  | Oscl_Vector< uint32, OsclMemAllocator > * | aPacketLen = NULL,
|  | Oscl_Vector< OsclNetworkAddress, OsclMemAllocator > * | aPacketSource = NULL
| ) |

  | Receive Data. This is an asynchronous method. Parameters:
  aPtr: | Buffer to receive incoming data
  aMaxLen: | Length of buffer.
  aAddress: | (output) Source address.
  aTimeoutMsec: | Timeout in milliseconds, or (-1) for infinite wait.
  aMultiRecvLimit | (optional input): Configures multiple packet receive mode. As long as there are packets queued at the socket and at least aMultiRecvLimit bytes are available in the buffer, recvfrom operations will continue. A value of zero disabled multiple packet mode. The individual packet lengths can be retrieved in the aPacketLen parameter; and the individual packet source addresses can be retrieved in the aPacketSource parameter.
  aPacketLen: | (optional output) a vector of packet lengths, in case multiple packets were received.
  aPacketSource: | (optional output) a vector of source addresses, in case multiple packets were received.
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 OsclUDPSocket::SendTo | ( | const uint8 * | aPtr,
|  | uint32 | aLen,
|  | OsclNetworkAddress & | aAddress,
|  | int32 | aTimeoutMsec = -1
| ) |

  | Send Data. This is an asynchronous method. Parameters:
  aPtr: | Data to send.
  aLen: | Length of data to send.
  aAddress: | Destination 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 int32 OsclUDPSocket::SetMulticastTTL | ( | int32 | aTTL | ) |

  | Controls the number of intermediate systems through which a multicast datagram can be forwarded. Parameters:
  aTTL:Specifies | the time-to-live value for multicast datagrams sent through this socket.
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 OsclUDPSocket::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 OsclUDPSocket::SetRecvBufferSize | ( | uint32 | size | ) |

  | Set the buffer size of the socket This is a synchronous method. Parameters:
  size: | buffer size
Returns: Returns OsclErrNone for success, or a platform-specific error code. May throw an OsclErrNotSupported Exception.

OSCL_IMPORT_REF int32 OsclUDPSocket::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 OsclUDPSocket::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 OsclUDPSocket::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