PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBSocket
Wrapper Class for the ISocket interface.
#include <SFBSocket.h.hpp>
class SFBSocket : public SFBAStream;
SFMTYPEDEFWRAPPER(SFBSocket)

Inheritance diagram

 Inheritance diagram of SFBSocketClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
O O O O

Reference

BREW API ISocket

Member

Public Functions
SFCError Accept( SFBSocketSmpPtr socket )
The accept function is used on a listening TCP socket to retrieve an incoming connection.
SFCError Bind( INAddr addr , INPort port )
Associate a local address and port with the socket. The bind function is used on an unconnected socket.
SFCError Bind( SFXSocketAddressConstRef dest )
Associate a local address and port with the socket. The bind function is used on an unconnected socket.
Void Cancel( PFNNOTIFY notify = null , VoidPtr data = null )
This function allows an application to cancel (un-register) a callback function that has been previously registered using SFBSocket::Readable(), SFBSocket::Writeable().
SFCError Close( Void )
Causes a socket to be closed. In the case of TCP, any connection will be terminated gracefully.
SFCError Connect( INAddr addr , INPort port , PFNCONNECTCB notify , VoidPtr data = null )
Attempt to initiate a TCP connection to the specified address and port.
SFCError Connect( SFXSocketAddressConstRef dest , PFNCONNECTCB notify , VoidPtr data = null )
Attempt to initiate a TCP connection to the specified address and port.
Void DbgMark( ACharConstPtr file , UInt32 line )
Mark an ISocket with __FILE__ and __LINE__ for debugging purposes.
SFCError GetLastError( Void )
Return the last error that occurred with the given Socket.
SFCError GetOpt( SInt32 level , SInt32 optName , VoidPtr optVal , SInt32Ptr optSize )
Get options for a socket.
SFCError GetOpt( SInt32 level , SInt32 optName , SFXBufferPtr opt )
Get options for a socket.
SFCError GetPeerName( INAddr* addr , INPort* port )
Return the remote IP address and port of the connected peer.
SFCError GetPeerName( SFXSocketAddressPtr dest )
Return the remote IP address and port of the connected peer.
SFXSocketAddress GetPeerName( Void )
Return the remote IP address and port of the connected peer.
SFCError GetSDBAckInfo( AEESDBAckInfo * info )
Get information received by SDB Ack.
SFCError GetSockName( INAddr* addr , INPort* port )
Return the local IP address and port of the socket.
SFCError GetSockName( SFXSocketAddressPtr dest )
Return the local IP address and port of the socket.
SFXSocketAddress GetSockName( Void )
Return the local IP address and port of the socket.
SFCError IOCtl( SInt32 option , UInt32 value )
Control over the behavior of an ISocket, for example connect time-outs.
SFCError Listen( SInt32 maxPending )
Perform a passive open for connections,
SInt32 ReadV( SockIOBlock* ioblocks , UInt16 count )
Read data from a socket into one or more buffers.
SFCError Realize( Void )
Acquires an IP address and ensures that the underlying network layer is ready for communication.
SInt32 RecvFrom( VoidPtr buff , UInt16 bytes , UInt16 flags , INAddr* addr , INPort* port )
Read data from UDP socket and records the IP address and port of the sender if non-null.
SInt32 RecvFrom( SFXBufferPtr buff , UInt16 flags , INAddr* addr , INPort* port )
Read data from UDP socket and records the IP address and port of the sender if non-null.
SInt32 RecvFrom( VoidPtr buff , UInt16 bytes , UInt16 flags , SFXSocketAddressPtr sender )
Read data from UDP socket and records the IP address and port of the sender if non-null.
SInt32 RecvFrom( SFXBufferPtr buff , UInt16 flags , SFXSocketAddressPtr sender )
Read data from UDP socket and records the IP address and port of the sender if non-null.
SInt32 SendTo( VoidPtr buff , UInt16 bytes , UInt16 flags , INAddr addr , INPort port )
Send a UDP packet to the specified IP address and port from the local port bound to the socket.
SInt32 SendTo( SFXBufferPtr buff , UInt16 flags , INAddr addr , INPort port )
Send a UDP packet to the specified IP address and port from the local port bound to the socket.
SInt32 SendTo( VoidPtr buff , UInt16 bytes , UInt16 flags , SFXSocketAddressConstRef dest )
Send a UDP packet to the specified IP address and port from the local port bound to the socket.
SInt32 SendTo( SFXBufferPtr buff , UInt16 flags , SFXSocketAddressConstRef dest )
Send a UDP packet to the specified IP address and port from the local port bound to the socket.
SFCError SetOpt( SInt32 level , SInt32 optName , VoidPtr optVal , SInt32 optSize )
Set options for a socket.
SFCError SetOpt( SInt32 level , SInt32 optName , SFXBufferConstRef opt )
Set options for a socket.
SFCError Shutdown( SInt32 how )
Cause all or part of a full-duplex connection to be terminated gracefully.
SInt32 Write( VoidPtr buff , UInt32 bytes )
Write data to a connected socket from a single buffer.
SInt32 Write( SFXBufferPtr buff )
Write data to a connected socket from a single buffer.
SInt32 WriteV( SockIOBlock* ioblocks , UInt16 count )
Write data to a connected socket.
Void Writeable( PFNNOTIFY notify , VoidPtr data = null )
Register a callback function to be invoked by the AEE when a non-blocking write operation on the specified socket can make progress.
SInt32 Read( VoidPtr buffer , UInt32 count ) (inherits from SFBAStream)
Attempt to read data from a stream, and returns the number of bytes read. If no data is available for reading, it returns the value AEE_STREAM_WOULDBLOCK.
SInt32 Read( SFXBufferPtr buffer ) (inherits from SFBAStream)
Attempt to read data from a stream, and returns the number of bytes read. If no data is available for reading, it returns the value AEE_STREAM_WOULDBLOCK.
Void Readable( PFNNOTIFY notify , VoidPtr data = null ) (inherits from SFBAStream)
Register a callback that checks whether data is available to be read. It is called when the SFBAStream::Read() returns AEE_STREAM_WOULDBLOCK.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBSocket::Accept
The accept function is used on a listening TCP socket to retrieve an incoming connection.
[ public ]
SFCError Accept(
    SFBSocketSmpPtr socket   // pointer to the newly accepted SFBSocket interface 
);

Version

Supported in BREW 2.1 or later.

Reference

BREW API ISOCKET_Accept | SFBSocket::Listen | SFBAStream::Readable


SFBSocket::Bind
Associate a local address and port with the socket. The bind function is used on an unconnected socket.
[ public ]
SFCError Bind(
    INAddr addr   // IP Address
    INPort port   // port
);
[ public ]
SFCError Bind(
    SFXSocketAddressConstRef dest   // IP Address and Port
);

Reference

BREW API ISOCKET_Bind


SFBSocket::Cancel
This function allows an application to cancel (un-register) a callback function that has been previously registered using SFBSocket::Readable(), SFBSocket::Writeable().
[ public ]
Void Cancel(
    PFNNOTIFY notify = null   // pointer to the callback function that needs to be cancelled
    VoidPtr data = null       // callback data that was used to register the callback
);

Reference

BREW API ISOCKET_Cancel | PFNNOTIFY


SFBSocket::Close
Causes a socket to be closed. In the case of TCP, any connection will be terminated gracefully.
[ public ]
SFCError Close(Void);

Version

Supported in BREW 2.1 or later.

Reference

BREW API ISOCKET_Close | SFBAStream::Readable | SFBSocket::Writeable


SFBSocket::Connect
Attempt to initiate a TCP connection to the specified address and port.
[ public ]
SFCError Connect(
    INAddr addr           // IP Address
    INPort port           // port
    PFNCONNECTCB notify   // address of the callback function that is invoked
                          // by AEE when the connect operation either succeeds or fails
    VoidPtr data = null   // user-defined data that is passed to the callback function when it is invoked
);
[ public ]
SFCError Connect(
    SFXSocketAddressConstRef dest   // IP Address and Port
    PFNCONNECTCB notify             // address of the callback function that is invoked
                                    // by AEE when the connect operation either succeeds or fails
    VoidPtr data = null             // user-defined data that is passed to the callback function when it is invoked
);

Reference

BREW API ISOCKET_Connect | PFNCONNECTCB


SFBSocket::DbgMark
Mark an ISocket with __FILE__ and __LINE__ for debugging purposes.
[ public ]
Void DbgMark(
    ACharConstPtr file   // __FILE__ 
    UInt32 line          // __LINE__ 
);

Version

Supported in BREW 2.1 or later.

Reference

BREW API ISOCKET_DbgMark | SFBSocket::IOCtl


SFBSocket::GetLastError
Return the last error that occurred with the given Socket.
[ public ]
SFCError GetLastError(Void);

Reference

BREW API ISOCKET_GetLastError


SFBSocket::GetOpt
Get options for a socket.
[ public ]
SFCError GetOpt(
    SInt32 level        // option level (see AEESockOpt)
    SInt32 optName      // option name (see AEESockOpt) 
    VoidPtr optVal      // pointer to the data type appropriate for the option
    SInt32Ptr optSize   // pointer to size of optVal
);
[ public ]
SFCError GetOpt(
    SInt32 level       // option level (see AEESockOpt) 
    SInt32 optName     // option name (see AEESockOpt) 
    SFXBufferPtr opt   // pointer to the buffer appropriate for the option
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • opt is null: SFERR_INVALID_PARAM
  • Operation in progress : AEE_NET_WOULDBLOCK
  • Operation failed : AEE_NET_ERROR

Version

This function is available in BREW 3.1.

Reference

BREW API ISOCKET_GetOpt | SFBSocket::SetOpt | SFBAStream::Readable


SFBSocket::GetPeerName
Return the remote IP address and port of the connected peer.
[ public ]
SFCError GetPeerName(
    INAddr* addr   // pointer to the IP Address in network byte order 
    INPort* port   // pointer to the port in network byte order
);
[ public ]
SFCError GetPeerName(
    SFXSocketAddressPtr dest   // pointer to the SFXSocketAddress
);
[ public ]
SFXSocketAddress GetPeerName(Void);

Reference

BREW API ISOCKET_GetPeerName


SFBSocket::GetSDBAckInfo
Get information received by SDB Ack.
[ public ]
SFCError GetSDBAckInfo(
    AEESDBAckInfo * info   // pointer to a AEESDBAckInfo structure
);

Version

Introduced BREW Client 3.1.5 SP01 or 4.0.2

Reference

BREW API ISocket_GetSDBAckInfo


SFBSocket::GetSockName
Return the local IP address and port of the socket.
[ public ]
SFCError GetSockName(
    INAddr* addr   // pointer to the IP Address t in network byte order
    INPort* port   // pointer to the IP Address t in network byte order
);
[ public ]
SFCError GetSockName(
    SFXSocketAddressPtr dest   // pointer to the SFXSocketAddress
);
[ public ]
SFXSocketAddress GetSockName(Void);

Version

Supported in Brew 2.1 or later.

Reference

BREW API ISOCKET_GetSockName


SFBSocket::IOCtl
Control over the behavior of an ISocket, for example connect time-outs.
[ public ]
SFCError IOCtl(
    SInt32 option   // the option id 
    UInt32 value    // the option value 
);

Reference

BREW API ISOCKET_IOCtl


SFBSocket::Listen
Perform a passive open for connections,
[ public ]
SFCError Listen(
    SInt32 maxPending   // the maximum number of pending connections
);

Version

Supported in Brew 2.1 or later.

Reference

BREW API ISOCKET_Listen | SFBSocket::Accept | SFBSocket::Writeable


SFBSocket::ReadV
Read data from a socket into one or more buffers.
[ public ]
SInt32 ReadV(
    SockIOBlock* ioblocks   // array of SockIOBlock structures into which data can be read
    UInt16 count            // specifies the number of entries in the iov array
);

Reference

BREW API ISOCKET_ReadV | SockIOBlock


SFBSocket::Realize
Acquires an IP address and ensures that the underlying network layer is ready for communication.
[ public ]
SFCError Realize(Void);

Version

Supported in Brew 2.1 or later.

Reference

BREW API ISOCKET_Realize


SFBSocket::RecvFrom
Read data from UDP socket and records the IP address and port of the sender if non-null.
[ public ]
SInt32 RecvFrom(
    VoidPtr buff   // buffer to hold the received data
    UInt16 bytes   // size of the buffer, in terms of number of bytes
    UInt16 flags   // unused, must be set to 0
    INAddr* addr   // pointer to the IP Address in network byte order
    INPort* port   // pointer to the port in network byte order
);
[ public ]
SInt32 RecvFrom(
    SFXBufferPtr buff   // buffer to hold the received data, 
                        // the size is converted into UInt16 when called by API
    UInt16 flags        // unused, must be set to 0
    INAddr* addr        // pointer to the IP Address in network byte order
    INPort* port        // pointer to the port in network byte order
);
[ public ]
SInt32 RecvFrom(
    VoidPtr buff                 // buffer to hold the received data
    UInt16 bytes                 // size of the buffer, in terms of number of bytes
    UInt16 flags                 // unused, must be set to 0
    SFXSocketAddressPtr sender   // the IP Address and Port of the sender
);
[ public ]
SInt32 RecvFrom(
    SFXBufferPtr buff            // buffer to hold the received data, 
                                 // the size is converted into UInt16 when called by API
    UInt16 flags                 // unused, must be set to 0
    SFXSocketAddressPtr sender   // the IP Address and Port of the sender
);

Reference

BREW API ISOCKET_RecvFrom


SFBSocket::SendTo
Send a UDP packet to the specified IP address and port from the local port bound to the socket.
[ public ]
SInt32 SendTo(
    VoidPtr buff   // buffer containing data to be sent
    UInt16 bytes   // size of the buffer, in terms of number of bytes
    UInt16 flags   // unused, must be set to 0
    INAddr addr    // IP Address
    INPort port    // port
);
[ public ]
SInt32 SendTo(
    SFXBufferPtr buff   // buffer containing data to be sent. 3
                        // if null, do nothing and return AEE_NET_ERROR
    UInt16 flags        // unused, must be set to 0
    INAddr addr         // IP Address
    INPort port         // port
);
[ public ]
SInt32 SendTo(
    VoidPtr buff                    // buffer containing data to be sent
    UInt16 bytes                    // size of the buffer, in terms of number of bytes
    UInt16 flags                    // unused, must be set to 0
    SFXSocketAddressConstRef dest   // IP Address and Port of the destination
);
[ public ]
SInt32 SendTo(
    SFXBufferPtr buff               // buffer containing data to be sent. 
                                    // if null, do nothing and return AEE_NET_ERROR
    UInt16 flags                    // unused, must be set to 0
    SFXSocketAddressConstRef dest   // IP Address and Port of the destination
);

Reference

BREW API ISOCKET_SendTo


SFBSocket::SetOpt
Set options for a socket.
[ public ]
SFCError SetOpt(
    SInt32 level     // option level (see AEESockOpt) 
    SInt32 optName   // option name (see AEESockOpt)  
    VoidPtr optVal   // pointer to the data type appropriate for the option
    SInt32 optSize   // size of optVal
);
[ public ]
SFCError SetOpt(
    SInt32 level            // option level (see AEESockOpt) 
    SInt32 optName          // option name (see AEESockOpt)  
    SFXBufferConstRef opt   // pointer to the data type appropriate for the option
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • opt is null: SFERR_INVALID_PARAM
  • Operation in progress : AEE_NET_WOULDBLOCK
  • operation failed : AEE_NET_ERROR

Version

This function is available in BREW 3.1.

Reference

BREW API ISOCKET_SetOpt | SFBSocket::GetOpt | SFBSocket::Writeable


SFBSocket::Shutdown
Cause all or part of a full-duplex connection to be terminated gracefully.
[ public ]
SFCError Shutdown(
    SInt32 how   // dictates which portion(s) of the connection to shutdown 
);

Version

Supported in Brew 2.1 or later.

Reference

BREW API ISOCKET_Shutdown | SFBSocket::Writeable


SFBSocket::Write
Write data to a connected socket from a single buffer.
[ public ]
SInt32 Write(
    VoidPtr buff   // pointer to the buffer from which the data is sent
    UInt32 bytes   // specifies the size of the buffer in terms of number of bytes in the buffer.
                   // in BREW 2.0 it is of UInt16
);
[ public ]
SInt32 Write(
    SFXBufferPtr buff   // buffer
                        // if null, do nothing and return AEE_NET_ERROR
);

Description

In BREW 2.0, the size value is converted into UInt16 when called by the API.

Reference

BREW API ISOCKET_Write


SFBSocket::WriteV
Write data to a connected socket.
[ public ]
SInt32 WriteV(
    SockIOBlock* ioblocks   // an array of SockIOBlocks containing the individual buffers to be sent
    UInt16 count            // number of entries inside the SockIOBlock structure
);

Reference

BREW API ISOCKET_WriteV | SockIOBlock


SFBSocket::Writeable
Register a callback function to be invoked by the AEE when a non-blocking write operation on the specified socket can make progress.
[ public ]
Void Writeable(
    PFNNOTIFY notify      // address of the callback function. 
                          // this function is invoked by AEE when the socket becomes ready 
                          // to receive data or when it is ready to be closed. 
                          // if this is null, it cancels the Writeable callback function 
                          // registered by a previous call to SFBSOCKET::Writeable()
    VoidPtr data = null   // user-defined data that is passed to the callback function when it is invoked
);

Reference

BREW API ISOCKET_Writeable | PFNNOTIFY