Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <wapmessage.h>
Link against: wapmsgcli.lib

Class CWapBoundDatagramService

class CWapBoundDatagramService : public CBase;

Description

Sends and receives datagrams over WDP using a specified local port.

The class is an ECom plug-in interface. Clients use CWapBoundDatagramService::NewL() to request an implementation of the interface, and then call the interface's virtual functions to access the implementation's services.

The use of the plug-in architecture allows different implementations to use different underlying WAP stacks.

Functions can return system wide error codes, and also API-specific errors as defined in wapmsgerr.h.

Derivation

Members

Defined in CWapBoundDatagramService:

Inherited from CBase:


Construction and destruction


NewL()

IMPORT_C static CWapBoundDatagramService* NewL();

Description

Allocates and creates a new CWapBoundDatagramService object.

Return value

CWapBoundDatagramService *

A new CWapBoundDatagramService object.

Leave codes

System

wide error codes


NewL(const TUid &)

IMPORT_C static CWapBoundDatagramService* NewL(const TUid &aImplementation);

Description

Allocates and creates a new CWapBoundDatagramService object.

Parameters

const TUid &aImplementation

Return value

CWapBoundDatagramService *

A new CWapBoundDatagramService object.

Leave codes

System

wide error codes


~CWapBoundDatagramService()

IMPORT_C virtual ~CWapBoundDatagramService();

Description

Destructor


CWapBoundDatagramService()

protected: IMPORT_C CWapBoundDatagramService();

Description


ConstructL()

protected: IMPORT_C void ConstructL();

Description

[Top]


Member functions


Connect(Wap::TBearer,Wap::TPort,TInetAddr)

virtual TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort, TInetAddr aInetAddr)=0;

Description

Connects to the WAP stack, opening an endpoint that can be used to listen for subsequent incoming datagrams.

This overload of CWapBoundDatagramService::Connect(Wap::TBearer,Wap::TPort,TInetAddr) allows an IP address associated with a network interface to be specified. In multihomed systems, this can be used to specify the network interface to which the endpoint should be bound.

All CWapBoundDatagramService implementations must automatically close this endpoint upon destruction.

Parameters

Wap::TBearer aBearer

The bearer to listen on. Use EAll to specify all bearers.

Wap::TPort aPort

The port to listen on. If set to 0, a local port will be chosen for the client's first CWapBoundDatagramService::SendTo(const TDesC8 &,Wap::TPort,const TDesC8 &,Wap::TBearer)

TInetAddr aInetAddr

The IP address of the network interface that should be used in a multihomed system.

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


Connect(Wap::TBearer,Wap::TPort)

virtual TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort)=0;

Description

Connects to the WAP stack, opening an endpoint that can be used to listen for subsequent incoming datagrams.

All CWapBoundDatagramService implementations must automatically close this endpoint upon destruction.

Parameters

Wap::TBearer aBearer

The bearer to listen on. Use EAll to specify all bearers.

Wap::TPort aPort

The port to listen on. If set to 0, a local port will be chosen for the client's first CWapBoundDatagramService::SendTo(const TDesC8 &,Wap::TPort,const TDesC8 &,Wap::TBearer)

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


SendTo(const TDesC8 &,Wap::TPort,const TDesC8 &,Wap::TBearer)

virtual TInt SendTo(const TDesC8 &aRemoteHost, Wap::TPort aRemotePort, const TDesC8 &aBuffer, Wap::TBearer aBearer)=0;

Description

Sends data to a remote endpoint.

Parameters

const TDesC8 &aRemoteHost

The address of the remote host to which to send the data. The format of the address is bearer-specific.

Wap::TPort aRemotePort

The port on the remote host to which the data will be sent

const TDesC8 &aBuffer

The data buffer to be sent

Wap::TBearer aBearer

The bearer to be used, if the bound connection was opened with EAll

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


AwaitRecvDataSize(TPckg< TUint16 > &,TRequestStatus &)

virtual TInt AwaitRecvDataSize(TPckg< TUint16 > &aDataSizePckg, TRequestStatus &aReqStatus)=0;

Description

Waits for a datagram to be received, and discovers the size of buffer required to retrieve it.

This asynchronous method waits for a datagram to be received and will then complete allowing the client to discover how large a buffer is needed to retrieve the entire datagram that has been received. A later call to CWapBoundDatagramService::RecvFrom(TDes8 &,Wap::TPort &,TDes8 &,TBool &,TRequestStatus &,TUint32) with a buffer of sufficient size will then allow the client to retrieve the datagram fully.

Parameters

TPckg< TUint16 > &aDataSizePckg

On completion, the size of data received, in bytes

TRequestStatus &aReqStatus

Asynchonrous status word, used to signal when a data size is known

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


RecvFrom(TDes8 &,Wap::TPort &,TDes8 &,TBool &,TRequestStatus &,TUint32)

virtual TInt RecvFrom(TDes8 &aRemoteHost, Wap::TPort &aRemotePort, TDes8 &aBuffer, TBool &aTruncated, TRequestStatus &aReqStatus, TUint32 aTimeout)=0;

Description

Receives data on a bound port.

An asynchronous notification is sent to the client when data arrives.

Parameters

TDes8 &aRemoteHost

On completion, the bearer-dependent address of the remote host from which the data was received

Wap::TPort &aRemotePort

On completion, the port on the remote host from which the data was received

TDes8 &aBuffer

A client-allocated data buffer that on completion is filled with data received. Data that overflows the buffer is discarded.

TBool &aTruncated

On completion, indicates whether the received datagram was truncated to fit in the client's supplied buffer

TRequestStatus &aReqStatus

Asynchronous status word, used to notify the client that a datagram was received

TUint32 aTimeout

An optional millisecond time-out which allows a timed read to be made. If no data is received within the timeout period, the request completes with KErrTimedOut. If a value of 0 is supplied, the timeout is infinite.

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


CancelRecv()

virtual void CancelRecv()=0;

Description

Cancels a previously asynchronous CWapBoundDatagramService::RecvFrom(TDes8 &,Wap::TPort &,TDes8 &,TBool &,TRequestStatus &,TUint32) or CWapBoundDatagramService::AwaitRecvDataSize(TPckg< TUint16 > &,TRequestStatus &) request.

If a datagram arrives at the local host, it will be discarded.


GetLocalPort(Wap::TPort &)

virtual TInt GetLocalPort(Wap::TPort &aPort)=0;

Description

Gets the local port of this endpoint.

This is useful if the port was chosen automatically.

Parameters

Wap::TPort &aPort

On return, the port number

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


GetLocalAddress(HBufC8 *&)

virtual TInt GetLocalAddress(HBufC8 *&aLocalHost)=0;

Description

Gets the local address of this endpoint.

Parameters

HBufC8 *&aLocalHost

On return, the address of the local host. Clients must pass in a reference to a NULL HBufC8 pointer. The function allocates a new HBufC8 buffer to hold the address, and passes ownership of the buffer to the client.

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


GetBearer(Wap::TBearer &)

virtual TInt GetBearer(Wap::TBearer &aBearer)=0;

Description

Gets the bearer on which a received datagram arrived.

This is useful when EAll was specified as the bearer in CWapBoundDatagramService::Connect(Wap::TBearer,Wap::TPort,TInetAddr).

Parameters

Wap::TBearer &aBearer

On return, the bearer

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.


GetDatagramSizes(TUint16 &,TUint16 &)

virtual TInt GetDatagramSizes(TUint16 &aMaxSize, TUint16 &aNominalSize)=0;

Description

Queries the WDP bearer for its maximum datagram size and its nominal datagram size.

The nominal size is the size within which a datagram won't have to be split into smaller individual messages and then re-assembled at the other end.

The function will fail for a stream connection.

Parameters

TUint16 &aMaxSize

On return, the maximum datagram size

TUint16 &aNominalSize

On return, the nominal datagram size

Return value

TInt

KErrNone on successful completion, or one of the system error codes on failure.