RSocket Class Reference

#include <es_sock.h>

Link against: esock.lib

class RSocket : public RCommsSubSession

Inherits from

Public Member Enumerations
enumTShutdown { ENormal, EStopInput, EStopOutput, EImmediate }
Public Member Functions
RSocket()
IMPORT_C voidAccept(RSocket &, TRequestStatus &)
IMPORT_C voidAccept(RSocket &, TDes8 &, TRequestStatus &)
IMPORT_C TIntBind(TSockAddr &)
IMPORT_C voidCancelAccept()
IMPORT_C voidCancelAll()
IMPORT_C voidCancelConnect()
IMPORT_C voidCancelIoctl()
IMPORT_C voidCancelRead()
IMPORT_C voidCancelRecv()
IMPORT_C voidCancelSend()
IMPORT_C voidCancelWrite()
IMPORT_C voidClose()
IMPORT_C voidConnect(TSockAddr &, TRequestStatus &)
IMPORT_C voidConnect(TSockAddr &, const TDesC8 &, TDes8 &, TRequestStatus &)
IMPORT_C TIntGetDisconnectData(TDes8 &)
IMPORT_C TIntGetOpt(TUint, TUint, TDes8 &)
IMPORT_C TIntGetOpt(TUint, TUint, TInt &)
IMPORT_C TIntInfo(TProtocolDesc &)
IMPORT_C voidIoctl(TUint, TRequestStatus &, TDes8 *, TUint)
IMPORT_C TIntListen(TUint)
IMPORT_C TIntListen(TUint, const TDesC8 &)
IMPORT_C voidLocalName(TSockAddr &)
IMPORT_C TUintLocalPort()
IMPORT_C TIntName(TName &)
IMPORT_C TIntOpen(RSocketServ &, TUint, TUint, TUint)
IMPORT_C TIntOpen(RSocketServ &, TUint, TUint, TUint, RConnection &)
IMPORT_C TIntOpen(RSocketServ &, TUint, TUint, TUint, RSubConnection &)
IMPORT_C TIntOpen(RSocketServ &, const TDesC &)
IMPORT_C TIntOpen(RSocketServ &)
IMPORT_C voidRead(TDes8 &, TRequestStatus &)
IMPORT_C voidRecv(TDes8 &, TUint, TRequestStatus &)
IMPORT_C voidRecv(TDes8 &, TUint, TRequestStatus &, TSockXfrLength &)
IMPORT_C voidRecvFrom(TDes8 &, TSockAddr &, TUint, TRequestStatus &)
IMPORT_C voidRecvFrom(TDes8 &, TSockAddr &, TUint, TRequestStatus &, TSockXfrLength &)
IMPORT_C voidRecvOneOrMore(TDes8 &, TUint, TRequestStatus &, TSockXfrLength &)
IMPORT_C voidRecvOneOrMore(TDes8 &, TUint, TRequestStatus &)
IMPORT_C voidRemoteName(TSockAddr &)
IMPORT_C voidSend(const TDesC8 &, TUint, TRequestStatus &)
IMPORT_C voidSend(const TDesC8 &, TUint, TRequestStatus &, TSockXfrLength &)
IMPORT_C voidSendTo(const TDesC8 &, TSockAddr &, TUint, TRequestStatus &)
IMPORT_C voidSendTo(const TDesC8 &, TSockAddr &, TUint, TRequestStatus &, TSockXfrLength &)
IMPORT_C TIntSetLocalPort(TInt)
IMPORT_C TIntSetOpt(TUint, TUint, const TDesC8 &)
IMPORT_C TIntSetOpt(TUint, TUint, TInt)
IMPORT_C voidShutdown(TShutdown, TRequestStatus &)
IMPORT_C voidShutdown(TShutdown, const TDesC8 &, TDes8 &, TRequestStatus &)
IMPORT_C TIntTransfer(RSocketServ &, const TDesC &)
IMPORT_C voidWrite(const TDesC8 &, TRequestStatus &)
Inherited Functions
RSubSessionBase::CloseSubSession(TInt)
RSubSessionBase::CreateAutoCloseSubSession(RSessionBase &,TInt,const TIpcArgs &)
RSubSessionBase::CreateSubSession(const RSessionBase &,TInt)
RSubSessionBase::CreateSubSession(const RSessionBase &,TInt,const TIpcArgs &)
RSubSessionBase::RSubSessionBase()
RSubSessionBase::Send(TInt)const
RSubSessionBase::Send(TInt,const TIpcArgs &)const
RSubSessionBase::SendReceive(TInt)const
RSubSessionBase::SendReceive(TInt,TRequestStatus &)const
RSubSessionBase::SendReceive(TInt,const TIpcArgs &)const
RSubSessionBase::SendReceive(TInt,const TIpcArgs &,TRequestStatus &)const
RSubSessionBase::Session()const
RSubSessionBase::SubSessionHandle()const

Detailed Description

Provides a client endpoint to a protocol. It provides functions for socket creation, reading, writing, passive connection, active connection, setting addresses and querying addresses. Use this class as an endpoint for network type communications. It provides the following services:

reading from and writing to protocol

binding to addresses

active connecting

passive connection through the listen/accept model

Before using any of these services, a connection to a socket server session must have been made and the socket must be open.

Since v5.0

Member Enumeration Documentation

Enum TShutdown

Argument to RSocket::Shutdown() specifying how abruptly the shutdown occurs.

EnumeratorValueDescription
ENormal

Complete when socket output/input stopped.

EStopInput

Stop socket input and complete when output is stopped.

EStopOutput

Stop socket output and complete when input is stopped.

EImmediate

Stop socket input/output and complete (abortive close).

Constructor & Destructor Documentation

RSocket ( )

IMPORT_CRSocket()

Default Constructor

Member Function Documentation

Accept ( RSocket &, TRequestStatus & )

IMPORT_C voidAccept(RSocket &aBlankSocket,
TRequestStatus &aStatus
)

Facilitates a client/server connection from a remote socket.

Extracts the first pending connection on a queue of sockets, the queue size being previously specified by Listen(). On successful completion the blank socket is given the handle of the new socket and it may then be used to transfer data. After completion the accept socket may be used to make further connections with new blank sockets (see Open() on how to open a blank socket).

Accept() may be used for protocols which do not have the KSIConnectionLess flag in their protocol information.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aBlankSocketA socket opened as a blank socket.
aStatusOn completion, will contain an error code: see the system-wide error codes.

Accept ( RSocket &, TDes8 &, TRequestStatus & )

IMPORT_C voidAccept(RSocket &aBlankSocket,
TDes8 &aConnectData,
TRequestStatus &aStatus
)

Facilitates a client/server connection from a remote socket.

Extracts the first pending connection on a queue of sockets, the queue size being previously specified by Listen(). On successful completion the blank socket is given the handle of the new socket and it may then be used to transfer data. After completion the accept socket may be used to make further connections with new blank sockets (see Open() on how to open a blank socket).

This variant provides an additional descriptor argument to receive data which may have been sent in a connect request. If there is a pending connection in the listen queue when Accept() is called, the call will complete immediately. Otherwise it will wait until a socket becomes available in the queue and complete asynchronously.

Accept() may be used for protocols which do not have the KSIConnectionLess flag in their protocol information.

To receive data-in accepting, a protocol must have the flag KSIConnectData in its protocol information.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aBlankSocketA socket opened as a blank socket.
aConnectDataData which may have been received in connection.
aStatusOn completion, will contain an error code: see the system-wide error codes.

Bind ( TSockAddr & )

IMPORT_C TIntBind(TSockAddr &anAddr)

Sets the local address of a socket.

When a socket is opened it has no name associated with it, and binding is required so data can be routed to the socket.

Bind() should be called before Listen() or Connect(). The address supplied should be a derived class specific to the particular protocol the socket was opened on.

ParameterDescription
anAddrDesired local address of socket.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

CancelAccept ( )

IMPORT_C voidCancelAccept()

Cancels an outstanding accept operation.

Will cause any outstanding accept operation to complete prematurely.

CancelAll ( )

IMPORT_C voidCancelAll()

Cancels all outstanding operations.

Will cause all outstanding operations to complete prematurely.

Outstanding operations for a socket include: read, write, Ioctl, connect, accept and shutdown. All of these operations will be completed by this call.

CancelConnect ( )

IMPORT_C voidCancelConnect()

Cancels an outstanding connect operation.

Will cause any outstanding connect operation to complete prematurely.

The state of a socket after a connect is cancelled is defined by the characteristics of the protocol.

CancelIoctl ( )

IMPORT_C voidCancelIoctl()

Cancels an outstanding Ioctl() operation.

Will cause any outstanding Ioctl operation to complete prematurely.

The state of a socket after a connect is cancelled is defined by the characteristics of the protocol.

CancelRead ( )

IMPORT_C voidCancelRead()

Cancels an outstanding Read() operation.

Calling this function will cause any outstanding Read() operation to complete prematurely. The state of a socket after a receive is cancelled is defined by the characteristics of the protocol.

CancelRecv ( )

IMPORT_C voidCancelRecv()

Cancels an outstanding Recv() operation.

Calling this function will cause any outstanding receive operation to complete prematurely. The state of a socket after a receive is cancelled is defined by the characteristics of the protocol.

CancelSend ( )

IMPORT_C voidCancelSend()

Cancels an outstanding Send() operation.

Calling the function will cause any outstanding send operation to complete prematurely. The state of a socket after a send is cancelled is defined by the characteristics of the protocol.

CancelWrite ( )

IMPORT_C voidCancelWrite()

Cancels an outstanding Write() operation.

Calling the function will cause any outstanding Write() operation to complete prematurely. The state of a socket after a send is cancelled is defined by the characteristics of the protocol.

Close ( )

IMPORT_C voidClose()

Closes a socket.

If a socket has been opened using Open() then it should be closed using Close(). This will ensure all associated resources are released.

Closing serves two distinct purposes:

To release resources associated with the IPC channel to the socket server.

To disconnect a socket if it is connected.

If a socket is connected, then calling close is equivalent to calling Shutdown() with an argument of RSocket::ENormal, synchronously waiting for the request to complete, and then closing the IPC channel. If asynchronous or alternative methods of disconnecting are required then Shutdown() should be called before Close().

If the RSocketServ session on which a protocol was opened is closed, then all sockets associated with that session will be abortively closed and any further requests on the sockets will result in panics.

If a protocol has the flag KSIGracefulClose in its protocol information, when Close() is called on a connected socket, the socket will synchronously block until a response to a close request has been received or some other protocol condition causes the call to complete.

Connect ( TSockAddr &, TRequestStatus & )

IMPORT_C voidConnect(TSockAddr &anAddr,
TRequestStatus &aStatus
)

Connects to a remote host asynchronously.

The address provided specifies the address of the remote host.

A socket may only have one connect operation outstanding at any one time. Once the connect is completed, the socket is ready to send or receive data. If a socket is unbound - i.e. Bind() has not been called yet - then it will automatically have a local address allocated.

Connect() is always required for protocols which do not have the KSIConnectionLess flag in their protocol information. If a protocol has the KSIConnectionLess flag, then Connect() may be used to set the address for all data sent from the socket, in which case Send()/Write() may be used in addition to SendTo().

To use data in connection a protocol must have the flag KSIConnectData in its protocol information.

To cancel a connect use CancelConnect().

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
anAddrAddress of remote host.
aStatusOn completion, will contain an error code, see the system-wide error codes.

Connect ( TSockAddr &, const TDesC8 &, TDes8 &, TRequestStatus & )

IMPORT_C voidConnect(TSockAddr &anAddr,
const TDesC8 &aConnectDataOut,
TDes8 &aConnectDataIn,
TRequestStatus &aStatus
)

Connects to a remote host asynchronously.

The address provided specifies the address of the remote host.

Some protocols allow data to be sent in connect request packets which may be provided in the data-out descriptor. Some protocols may allow data to be sent in connect responses which may be collected in the data-in descriptor.

A socket may only have one connect operation outstanding at any one time. Once the connect is completed, the socket is ready to send or receive data. If a socket is unbound - i.e. Bind() has not been called yet - then it will automatically have a local address allocated.

Connect() is always required for protocols which do not have the KSIConnectionLess flag in their protocol information. If a protocol has the KSIConnectionLess flag, then Connect() may be used to set the address for all data sent from the socket, in which case Send()/Write() may be used in addition to SendTo().

To use data in connection a protocol must have the flag KSIConnectData in its protocol information.

To cancel a connect use CancelConnect().

panic
EConnectingAlready if the socket is connection-oriented and a blocking connection is already in progress for the socket
capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
anAddrAddress of remote host.
aStatusOn completion, will contain an error code. KErrBadHandle if the socket has already been closed by the client; KErrAlreadyExists if the socket is already connected and it isn't a blocking connection; otherwise one of the system-wide error codes.

GetDisconnectData ( TDes8 & )

IMPORT_C TIntGetDisconnectData(TDes8 &aDesc)

Gets data for use in the disconnection of a socket, namely the remote name of the connected socket.

This data has been received in a protocol disconnect message.

To use the data in disconnection, a protocol must have the flagKSIConnectData in its protocol information.

ParameterDescription
aDescA descriptor to receive data.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

GetOpt ( TUint, TUint, TDes8 & )

IMPORT_C TIntGetOpt(TUintanOptionName,
TUintanOptionLevel,
TDes8 &anOption
)

Gets a socket option. The socket server has options which are generic to all sockets and protocols may add specific options.

Options available for all protocols can be got with anOptionLevel set to KSOLSocket. See individual protocol notes for other socket options.

capability
Dependent on the type of operation so deferred to PRT. See documentation of constant values used in aOptionName and aOptionLevel for more information
ParameterDescription
anOptionNameAn integer constant which identifies an option.
anOptionLevelAn integer constant which identifies level of an option.
anOptionOn return, option value packaged in a descriptor.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

GetOpt ( TUint, TUint, TInt & )

IMPORT_C TIntGetOpt(TUintanOptionName,
TUintanOptionLevel,
TInt &anOption
)

Gets a socket option. The socket server has options which are generic to all sockets and protocols may add specific options.

Options available for all protocols can be got with anOptionLevel set to KSOLSocket. See individual protocol notes for other socket options.

capability
Dependent on the type of operation so deferred to PRT. See documentation of constant values used in aOptionName and aOptionLevel for more information
ParameterDescription
anOptionNameAn integer constant which identifies an option.
anOptionLevelAn integer constant which identifies level of an option.
anOptionOn return, option value as an integer.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Info ( TProtocolDesc & )

IMPORT_C TIntInfo(TProtocolDesc &aProtocol)

Gets information in the protocol description for the protocol which a socket is opened on.

ParameterDescription
aProtocolA protocol description type to hold protocol information.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Ioctl ( TUint, TRequestStatus &, TDes8 *, TUint )

IMPORT_C voidIoctl(TUintaCommand,
TRequestStatus &aStatus,
TDes8 *aDesc = NULL,
TUintaLevel =  KLevelUnspecified
)

Applies an asynchronous I/O control operation on a socket. Data may be passed and received if a descriptor address is provided as an argument. Only one Ioctl() operation may be outstanding for each socket.

Commands available for all protocols can be set withaLevel set to KSOLSocket. See individual protocol notes for other commands.

capability
Dependent on the type of operation so deferred to PRT. See documentation of constant values used in aOptionName and aOptionLevel for more information
ParameterDescription
aCommandIoctl command.
aStatusOn completion, will contain an error code: see the system-wide error codes.
aDescPointer to a descriptor in which data may be sent and received on completion
aLevelControl operation level

Listen ( TUint )

IMPORT_C TIntListen(TUintqSize)

Sets up a socket to listen for incoming connections.

Before calling this procedure a socket should be opened on a specific protocol using Open() and the socket should be bound to a local address using Bind().

Listen() creates a queue to hold incoming connections which can be married with blank sockets using Accept(). The call also allows data to be sent back to connecting peers if a protocol allows data to be passed in connect responses. Once a listen queue has been created it will continue to allow peers to connect until it is full, at which point it will reject any incoming connections as specified by protocol behaviour. When a socket is accepted by the client a space is made available in the queue.

ParameterDescription
qSizeSize of listen queue.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Listen ( TUint, const TDesC8 & )

IMPORT_C TIntListen(TUintqSize,
const TDesC8 &aConnectData
)

Sets up a socket to listen for incoming connections.

Before calling this procedure a socket should be opened on a specific protocol using Open() and the socket should be bound to a local address using Bind().

Listen() creates a queue to hold incoming connections which can be married with blank sockets using Accept(). The call also allows data to be sent back to connecting peers if a protocol allows data to be passed in connect responses. Once a listen queue has been created it will continue to allow peers to connect until it is full, at which point it will reject any incoming connections as specified by protocol behaviour. When a socket is accepted by the client a space is made available in the queue.

To use data-in listening, a protocol must have the flag KSIConnectData in its protocol information.

ParameterDescription
qSizeSize of listen queue.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

LocalName ( TSockAddr & )

IMPORT_C voidLocalName(TSockAddr &anAddr)

Gets the local address of a bound socket.

The local address is set either by calling Bind(), or is automatically set when Connect() is called.

If a socket is created through Accept() then a socket will inherit the port of its parent unless otherwise specified by a protocol's behaviour.

Depending on a protocol implementation, additional information may be gained through this call.

ParameterDescription
anAddrLocal address which is filled in on return.

LocalPort ( )

IMPORT_C TUintLocalPort()

Gets the local port number of a bound socket.

Getting the local port is similar to getting the local name.

See also: LocalName() for a description.

Returns: The local port of a socket.

Name ( TName & )

IMPORT_C TIntName(TName &aName)

Gets a unique system name for the socket. The purpose of this is to identify the socket in a call to Transfer().

ParameterDescription
aNameSystem name for the socket

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Open ( RSocketServ &, TUint, TUint, TUint )

IMPORT_C TIntOpen(RSocketServ &aServer,
TUintaddrFamily,
TUintsockType,
TUintprotocol
)

Opens an implicit socket by creating a new subsession to the socket server. Implicit socket is not explicitly associated with any connection. The socket will choose the default connection for sending the packets.

Implicit socket accepts packets routed through any connection.

Opens a channel to a protocol identified by a tuple of constants. If a socket is the first to be opened for a protocol it will have the additional effect of loading the protocol in the socket server.

NOTE: Deprecated default connection scenario. Applications exercising the default connection scenario must (from 9.3 onwards) switch to explicit connection scenario.
  • The default connection scenario is where an application holding one started RConnection opens a socket without explicitly associating it with the RConnection. The explicit association can be made by passing the RConnection or a derived RSubConnection to an appropriate overload of RSocket::Open(...) (not this method).

  • The implicit connection scenario is where an application holding either none or many started RConnections (to different access points) opens a socket without explicitly associating it an RConnection.

  • The explicit connection scenario is where an application holding started RConnections opens a socket explicitly associating it with one of its RConnections.

Applications attempting to exercise the default connection scenario shall (from 9.3 onwards) receive an error from RSocket::Open(...). The actual error code is yet to be defined.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aServerThe socket server session.
addrFamilyA valid address constant for a protocol family.
sockTypeA valid socket type for the protocol.
protocolA protocol constant which identifies a specific protocol.

Returns: KErrNone if successful, otherwise another of the system-wide error codes

Open ( RSocketServ &, TUint, TUint, TUint, RConnection & )

IMPORT_C TIntOpen(RSocketServ &aServer,
TUintaddrFamily,
TUintsockType,
TUintprotocol,
RConnection &aConnection
)

Opens an explicit socket by creating a new subsession to the socket server. The socket is explicitly associated with the same underlying connection as an existing RConnection instance.

Socket traffic is directed to and from the specified connection only.

Note:

The association is instantaneous, in that the socket is associated with the interface that the RConnection is associated with at the present time. This association terminates when the underlying interface goes down.

since 7.0S
capability
Dependent Capability required depends on the type of connection so deferred to PRT
ParameterDescription
aServerThe socket server session.
addrFamilyA valid address constant for a protocol family.
sockTypeA valid socket type for the protocol.
protocolA protocol constant which identifies a specific protocol.
aConnectionExisting RConnection whose interface this socket will be associated with.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Open ( RSocketServ &, TUint, TUint, TUint, RSubConnection & )

IMPORT_C TIntOpen(RSocketServ &aServer,
TUintaddrFamily,
TUintsockType,
TUintprotocol,
RSubConnection &aSubConnection
)

Opens an explicit socket by creating a new subsession to the socket server. The socket is explicitly associated with the same underlying connection as an existing RSubConnection instance.

Socket traffic is directed to and from the specified connection only.

since 7.0S

capability
Dependent Capability required depends on the type of connection so deferred to PRT
ParameterDescription
aServerThe socket server session.
addrFamilyA valid address constant for a protocol family.
sockTypeA valid socket type for the protocol.
protocolA protocol constant which identifies a specific protocol.
aSubConnectionExisting RSubConnection this socket will be associated with.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Open ( RSocketServ &, const TDesC & )

IMPORT_C TIntOpen(RSocketServ &aServer,
const TDesC &aName
)

Opens an implicit socket by creating a new subsession to the socket server. Implicit socket is not explicitly associated with any connection. The socket will choose the default connection for sending the packets.

Implicit socket accepts packets routed through any connection.

Opens a channel to a protocol identified by a name. If a socket is the first to be opened for a protocol it will have the additional effect of loading the protocol in the socket server.

NOTE: Deprecated default connection scenario. Applications exercising the default connection scenario must (from 9.3 onwards) switch to explicit connection scenario.
  • The default connection scenario is where an application holding one started RConnection opens a socket without explicitly associating it with the RConnection. The explicit association can be made by passing the RConnection or a derived RSubConnection to an appropriate overload of RSocket::Open(...) (not this method).

  • The implicit connection scenario is where an application holding either none or many started RConnections (to different access points) opens a socket without explicitly associating it an RConnection.

  • The explicit connection scenario is where an application holding started RConnections opens a socket explicitly associating it with one of its RConnections.

Applications attempting to exercise the default connection scenario shall (from 9.3 onwards) receive an error from RSocket::Open(...). The actual error code is yet to be defined.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aServerThe socket server session.
aNameName of a protocol.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Open ( RSocketServ & )

IMPORT_C TIntOpen(RSocketServ &aServer)

Opens an implicit socket by creating a new subsession to the socket server. Implicit socket is not explicitly associated with any connection. The socket will choose the default connection for sending the packets.

Implicit socket accepts packets routed through any connection.

Provides a blank channel to the socket server which has no protocol associated. A socket opened in this manner is suitable as an argument to Accept(), which will marry the blank socket to a protocol when a connection is established to a remote endpoint.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aServerThe socket server session.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Read ( TDes8 &, TRequestStatus & )

IMPORT_C voidRead(TDes8 &aDesc,
TRequestStatus &aStatus
)

Receives data from a remote host.

For a stream-interfaced sockets, the function only completes when the full amount of requested data has been received (or the connection breaks). This means when the descriptor has been filled to its maximum length (not its current length). For a connection-oriented datagram-interface, the function completes when a datagram arrives even if it is not sufficient to fill the buffer.

Read() should only be used with connected sockets.

A socket may only have one receive operation outstanding at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data read will be placed.
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.

Recv ( TDes8 &, TUint, TRequestStatus & )

IMPORT_C voidRecv(TDes8 &aDesc,
TUintflags,
TRequestStatus &aStatus
)

Receives data from a remote host, allowing flags for protocol specific information.

For a stream-interfaced socket the function only completes when the full amount of requested data has been received (or the connection breaks). This means when the descriptor has been filled to its maximum length (not its current length).

For a datagram-interface socket, the function completes when one datagram arrives - even if it is not sufficient to fill the buffer. If the datagram does not fit in the buffer supplied then the remaining data will be lost.

Recv() should only be used with connected sockets.

A socket may only have one receive operation outstanding at any one time.

If a protocol's information flag is marked with KSIPeekData, then KSockReadPeek may be provided as a flag to Recv(). All other flags are protocol specific.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data received will be placed.
flagsFlags for protocol specific information.
aStatusOn return, KErrNone if successful, otherwise another of the system-wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.

Recv ( TDes8 &, TUint, TRequestStatus &, TSockXfrLength & )

IMPORT_C voidRecv(TDes8 &aDesc,
TUintflags,
TRequestStatus &aStatus,
TSockXfrLength &aLen
)

Receives data from a remote host, allowing flags for protocol specific information.

For a stream-interfaced sockets, the function only completes when the full amount of requested data has been received (or the connection breaks). This means when the descriptor has been filled to its maximum length (not its current length).

For a datagram-interface socket, the function completes when one datagram arrives - even if it is not sufficient to fill the buffer. If the datagram does not fit in the buffer supplied, remaining data may be retrieved using the Datagram Continuation feature.

This function implements the Datagram Continuation feature for PRTs implementing PRT1.5: the ability to read a datagram in parts. For a client request to read a datagram, using the TSockXfrLength parameter, remaining unread octets of the datagram are returned in the TSockXfrLength parameter. The client can then read the remaining octets by further reads with the 'KSockReadContinuation' flag OR'd into the flags field. Remaining octets are discarded upon the next read without the KSockReadContinuation flag set.

Recv() should only be used with connected sockets.

A socket may only have one receive operation outstanding at any one time.

If a protocol's information flag is marked with KSIPeekData, then KSockReadPeek may be provided as a flag to Recv(). All other flags are protocol specific.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data received will be placed.
flagsFlags for protocol specific information.
aStatusReference to the request status object. On completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.
aLenFor non-datagram sockets, on return, a length which indicates how much data was read. This is the same as length of the returned aDesc. For datagram sockets, this parameter returns the number of remaining unread octets.

RecvFrom ( TDes8 &, TSockAddr &, TUint, TRequestStatus & )

IMPORT_C voidRecvFrom(TDes8 &aDesc,
TSockAddr &anAddr,
TUintflags,
TRequestStatus &aStatus
)

Receives data from a remote host through a (possibly) unconnected socket and returns a source address.

Flags are provided to add protocol specific information.

A socket may only have one receive operation outstanding at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data read will be placed.
anAddrA remote source address for unconnected receives. Returns KAfInet6 in TSockAddr::Family() for IPv4 ICMP packets. Returns KAfInet for IPv4 TCP and UDP sockets.
flagsFlags which are passed through to protocol.
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.

RecvFrom ( TDes8 &, TSockAddr &, TUint, TRequestStatus &, TSockXfrLength & )

IMPORT_C voidRecvFrom(TDes8 &aDesc,
TSockAddr &anAddr,
TUintflags,
TRequestStatus &aStatus,
TSockXfrLength &aLen
)

Receives data from a remote host through a (possibly) unconnected socket where a source address is returned.

Flags are provided to add protocol specific information.

A socket may only have one receive operation outstanding at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data read will be placed
anAddrA remote source address for unconnected receives. Returns KAfInet6 in TSockAddr::Family() for IPv4 ICMP packets. Returns KAfInet for IPv4 TCP and UDP sockets.
flagsFlags which are passed through to protocol
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.
aLenFor non-datagram sockets, on return, a length which indicates how much data was read. This is the same as length of the returned aDesc. For datagram sockets, this parameter is not used.

RecvOneOrMore ( TDes8 &, TUint, TRequestStatus &, TSockXfrLength & )

IMPORT_C voidRecvOneOrMore(TDes8 &aDesc,
TUintflags,
TRequestStatus &aStatus,
TSockXfrLength &aLen
)

Receives data from a remote host and completes when data is available.

The function reads at least one byte of data, but will complete as soon as any data is available. The amount of data received is returned via the TSockXfrLength argument.

RecvOneOrMore() can only be used with stream-interfaced connected sockets; datagram interface sockets will return KErrNotSupported.

A socket may only have one receive operation outstanding at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data read will be placed.
flagsFlags which are passed through to protocol.
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.
aLenFor non-datagram sockets, on return, a length which indicates how much data was read. This is the same as length of the returned aDesc. For datagram sockets, this parameter is not used.

RecvOneOrMore ( TDes8 &, TUint, TRequestStatus & )

IMPORT_C voidRecvOneOrMore(TDes8 &aDesc,
TUintflags,
TRequestStatus &aStatus
)

Receives data from a remote host and completes when data is available.

The function reads at least one byte of data, but will complete as soon as any data is available. The amount of data received is returned via the TSockXfrLength argument.

RecvOneOrMore() can only be used with stream-interfaced connected sockets; datagram interface sockets will return KErrNotSupported.

A socket may only have one receive operation outstanding at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescA descriptor where data read will be placed.
flagsFlags which are passed through to protocol.
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates either that a remote connection is closed, and that no more data is available for reading, or the socket has been shutdown with option RSocket::EStopInput.

RemoteName ( TSockAddr & )

IMPORT_C voidRemoteName(TSockAddr &anAddr)

Gets the remote name of a connected socket.

The remote name of a socket is associated with the remote host a socket is connected to. The remote name is only valid for a connected socket. A socket is either connected through calling Connect() or Accept().

ParameterDescription
anAddrRemote address which is filled in on return.

Send ( const TDesC8 &, TUint, TRequestStatus & )

IMPORT_C voidSend(const TDesC8 &aDesc,
TUintsomeFlags,
TRequestStatus &aStatus
)

Sends data to a remote host on a connected socket with options set by protocol specific flags.

A socket may only have one send operation in progress at any one time. Send() should only be used with connected sockets.

If a protocol's information flag is marked with KSIUrgentData, then KSockWriteUrgent may be provided as a flag to Send(). All other flags are protocol specific.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescThe data to be sent.
someFlagsFlags which are passed through to protocol
aStatusOn return KErrNone if successful, otherwise another of the system-wide error codes. Note that KErrEof indicates that the socket has been shutdown with option EStopOutput.

Send ( const TDesC8 &, TUint, TRequestStatus &, TSockXfrLength & )

IMPORT_C voidSend(const TDesC8 &aDesc,
TUintsomeFlags,
TRequestStatus &aStatus,
TSockXfrLength &aLen
)

Sends data to a remote host on a connected socket with options set by protocol specific flags.

The length of the descriptor indicates the amount of data to be sent. The TSockXfrLength argument will return the amount of data actually sent.

A socket may only have one send operation in progress at any one time.

Send() should only be used with connected sockets.

If a protocol's information flag is marked with KSIUrgentData, then KSockWriteUrgent may be provided as a flag to Send(). All other flags are protocol specific.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aDescThe data to be sent.
someFlagsFlags which are passed through to protocol
aStatusOn return KErrNone if successful, otherwise another of the system-wide error codes. Note that KErrEof indicates that the socket has been shutdown with option EStopOutput
aLenFilled in with amount of data sent before completion

SendTo ( const TDesC8 &, TSockAddr &, TUint, TRequestStatus & )

IMPORT_C voidSendTo(const TDesC8 &aDesc,
TSockAddr &anAddr,
TUintflags,
TRequestStatus &aStatus
)

Sends data to a remote host through a (possibly) unconnected socket to a specified destination address.

Flags are provided to add protocol specific information. The length of the descriptor indicates the amount of data to be sent. A socket may only have one send operation in progress at any one time.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescThe data to be sent.
anAddrA remote destination address for unconnected sends
flagsFlags which are passed through to protocol
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates that the socket has been shutdown with option EStopOutput.

SendTo ( const TDesC8 &, TSockAddr &, TUint, TRequestStatus &, TSockXfrLength & )

IMPORT_C voidSendTo(const TDesC8 &aDesc,
TSockAddr &anAddr,
TUintflags,
TRequestStatus &aStatus,
TSockXfrLength &aLen
)

Sends data to a remote host through a (possibly) unconnected socket to a specified destination address.

Flags are provided to add protocol specific information. The length of the descriptor indicates the amount of data to be sent. A socket may only have one send operation in progress at any one time. The TSockXfrLength argument will return the amount of data sent.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescThe data to be sent.
anAddrA remote destination address for unconnected sends
flagsFlags which are passed through to protocol
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates that the socket has been shutdown with option EStopOutput. In the case of KSONonBlockingIO & writeFlowedoff, it has to return KerrWouldBlock, but it returns KErrNone for compatibiity
aLenFilled in with amount of data sent before completion

SetLocalPort ( TInt )

IMPORT_C TIntSetLocalPort(TIntaPort)

Sets the local port of a socket. Setting the local port is equivalent to calling Bind() with only the port set in the address.

ParameterDescription
aPortDesired local port of socket.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

SetOpt ( TUint, TUint, const TDesC8 & )

IMPORT_C TIntSetOpt(TUintanOptionName,
TUintanOptionLevel,
const TDesC8 &anOption =  TPtrC8(NULL, 0)
)

Sets a socket option. The socket server has options which are generic to all sockets and protocols may add specific options.

Options available for all protocols can be set with anOptionLevel set to KSOLSocket. See individual protocol notes for other socket options.

capability
Dependent on the type of operation so deferred to PRT. See documentation of constant values used in aOptionName and aOptionLevel for more information
ParameterDescription
anOptionNameAn integer constant which identifies an option.
anOptionLevelAn integer constant which identifies level of an option: i.e. an option level groups related options together.
anOptionOption value packaged in a descriptor.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

SetOpt ( TUint, TUint, TInt )

IMPORT_C TIntSetOpt(TUintanOptionName,
TUintanOptionLevel,
TIntanOption
)

Sets a socket option. The socket server has options which are generic to all sockets and protocols may add specific options.

Options available for all protocols can be set with anOptionLevel set to KSOLSocket. See individual protocol notes for other socket options.

capability
Dependent on the type of operation so deferred to PRT. See documentation of constant values used in aOptionName and aOptionLevel for more information
ParameterDescription
anOptionNameAn integer constant which identifies an option.
anOptionLevelAn integer constant which identifies level of an option: i.e. an option level groups related options together.
anOptionOption value as an integer.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Shutdown ( TShutdown, TRequestStatus & )

IMPORT_C voidShutdown(TShutdownaHow,
TRequestStatus &aStatus
)

Shuts down a connected socket - asynchronous.

This method is asynchronous as non emergency shutdown may take a while.

The shut down method allows input and output to be individually stopped for a protocol endpoint. For protocols which support data-in disconnect message, additional arguments are provided.

Shutdown() can be used for protocols which do not have the KSIConnectionLess flag in their protocol information.

To use data in disconnection a protocol must have the flag KSIDisconnectData in its protocol information.

There is no way to cancel a socket shutdown once it has started.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aHowShutdown option. All variants complete when a socket is disconnected. If the parameter is within the range of TShutdown values, pending read and write operations are cancelled. If the parameter is outside the range of TShutdown values, then the behaviour is as if ENormal were specified except that pending read and write operations are not cancelled. Note that the behaviour of using parameters outside the range of TShutdown values may change in a future release and should not be relied upon.
aStatusOn return KErrNone if successful, otherwise another of the system-wide error codes.

Shutdown ( TShutdown, const TDesC8 &, TDes8 &, TRequestStatus & )

IMPORT_C voidShutdown(TShutdownaHow,
const TDesC8 &aDisconnectDataOut,
TDes8 &aDisconnectDataIn,
TRequestStatus &aStatus
)

Shuts down a connected socket with disconnect data - asynchronous.

This method is asynchronous as non emergency shutdown may take a while.

The shut down method allows input and output to be individually stopped for a protocol endpoint. For protocols which support data-in disconnect message, additional arguments are provided.

Shutdown() can be used for protocols which do not have the KSIConnectionLess flag in their protocol information.

To use data in disconnection a protocol must have the flag KSIConnectData in its protocol information.

There is no way to cancel a socket shutdown once it has started.

capability
Dependent Capability required depends on the type of socket so deferred to PRT
ParameterDescription
aHowShutdown option. All variants complete when a socket is disconnected.
aDisconnectDataOutA descriptor containing data to be sent.
aDisconnectDataInA descriptor to receive data.
aStatusOn return KErrNone if successful, otherwise another of the system-wide error codes.

Transfer ( RSocketServ &, const TDesC & )

IMPORT_C TIntTransfer(RSocketServ &aServer,
const TDesC &aName
)

Transfers a socket from one socket server session to another. It creates the socket in the target session, and removes the socket from the source session. The call is made on an uninitialised RSocket object. The socket system name is used to identify the socket to transfer.

If the call fails, the socket that is being transferred remains with the original session. Success or failure can be checked on the originating socket by calling Info(), which returns KErrNone if the transfer failed, and KErrBadHandle if it succeeded.

Platsec considerations require that the source socket must set itself transferable before any attempt to transfer the socket to the destination socket. This is done using a setopt in the following way

		_LIT_SECURITY_POLICY_Cn(KProcPolicy, cap1,cap2,...capn);
		ret = destsock.SetOpt(KSOEnableTransfer, KSOLSocket, KProcPolicy().Package());

where cap1,cap2...capn are the capabilities that the destination process MUST have in order to affect the transfer.

An example is:

		_LIT_SECURITY_POLICY_C2(KProcPolicy, ECapabilityNetworkServices, ECapabilityNetworkControl);
		ret = destsock.SetOpt(KSOEnableTransfer, KSOLSocket, KProcPolicy().Package());

If the setOpt is not set or the destination process does not have sufficient capabilities then the function will return KErrPermissionDenied

capability
Dependent on the capabilities defined in the setOpt by the source Socket
ParameterDescription
aServerThe session into which to transfer the socket.
aNameThe system name, as obtained from a call to Name(), of the socket that you want to transfer.

Returns: KErrNone if successful, otherwise another of the system-wide error codes.

Write ( const TDesC8 &, TRequestStatus & )

IMPORT_C voidWrite(const TDesC8 &aDesc,
TRequestStatus &aStatus
)

Sends data to a remote host.

Write() should only be used with connected sockets.

capability
Dependent on the type of socket so deferred to PRT
ParameterDescription
aDescThe data to be sent.
aStatusOn completion, KErrNone if successful, otherwise one of the system wide error codes. Note that KErrEof indicates that the socket has been shutdown with option EStopOutput.