LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
osl::DatagramSocket Class Reference

A connectionless socket to send and receive datagrams. More...

#include <socket_decl.hxx>

Inheritance diagram for osl::DatagramSocket:
osl::Socket

Public Member Functions

 DatagramSocket (oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp, oslSocketType Type=osl_Socket_TypeDgram)
 Creates a datagram socket. More...
 
sal_Int32 recvFrom (void *pBuffer, sal_uInt32 BufferSize, SocketAddr *pSenderAddr=NULL, oslSocketMsgFlag Flag=osl_Socket_MsgNormal)
 Tries to receives BufferSize data from the socket, if no error occurs. More...
 
sal_Int32 sendTo (const SocketAddr &ReceiverAddr, const void *pBuffer, sal_uInt32 BufferSize, oslSocketMsgFlag Flag=osl_Socket_MsgNormal)
 Tries to send one datagram with BytesToSend size to the given ReceiverAddr. More...
 
- Public Member Functions inherited from osl::Socket
 Socket ()
 
 Socket (const Socket &socket)
 
 Socket (oslSocket socketHandle)
 
 Socket (oslSocket socketHandle, __sal_NoAcquire noacquire)
 The instance takes over the handle's ownership without acquiring the handle, but releases it within the dtor. More...
 
 ~Socket ()
 Destructor. More...
 
Socketoperator= (oslSocket socketHandle)
 Assignment operator. More...
 
Socketoperator= (const Socket &sock)
 Assignment operator. More...
 
bool operator== (const Socket &rSocket) const
 
bool operator== (const oslSocket socketHandle) const
 
void shutdown (oslSocketDirection Direction=osl_Socket_DirReadWrite)
 Closes a definite or both directions of the bidirectional stream. More...
 
void close ()
 Closes a socket. More...
 
void getLocalAddr (SocketAddr &Addr) const
 Retrieves the address of the local interface of this socket. More...
 
sal_Int32 getLocalPort () const
 Get the local port of the socket. More...
 
inline::rtl::OUString getLocalHost () const
 Get the hostname for the local interface. More...
 
void getPeerAddr (SocketAddr &Addr) const
 Retrieves the address of the remote host of this socket. More...
 
sal_Int32 getPeerPort () const
 Get the remote port of the socket. More...
 
inline::rtl::OUString getPeerHost () const
 Get the hostname for the remote interface. More...
 
bool bind (const SocketAddr &LocalInterface)
 Binds the socket to the specified (local) interface. More...
 
bool isRecvReady (const TimeValue *pTimeout=NULL) const
 Checks if read operations will block. More...
 
bool isSendReady (const TimeValue *pTimeout=NULL) const
 Checks if send operations will block. More...
 
bool isExceptionPending (const TimeValue *pTimeout=NULL) const
 Checks if a request for out-of-band data will block. More...
 
oslSocketType getType () const
 Queries the socket for its type. More...
 
sal_Int32 getOption (oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level=osl_Socket_LevelSocket) const
 Retrieves option-attributes associated with the socket. More...
 
bool setOption (oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level=osl_Socket_LevelSocket) const
 Sets the sockets attributes. More...
 
bool setOption (oslSocketOption option, sal_Int32 nValue)
 Convenience function for setting sal_Bool and sal_Int32 option values. More...
 
sal_Int32 getOption (oslSocketOption option) const
 Convenience function for retrieving sal_Bool and sal_Int32 option values. More...
 
bool enableNonBlockingMode (bool bNonBlockingMode)
 Enables/disables non-blocking mode of the socket. More...
 
bool isNonBlockingMode () const
 Query blocking mode of the socket. More...
 
void clearError () const
 clears the error status More...
 
oslSocketError getError () const
 returns a constant describing the last error for the socket system. More...
 
inline::rtl::OUString getErrorAsString () const
 Builds a string with the last error-message for the socket. More...
 
oslSocket getHandle () const
 Returns the underlying handle unacquired (The caller must acquire it to keep it). More...
 

Additional Inherited Members

- Protected Member Functions inherited from osl::Socket
 Socket (oslSocketType Type, oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp)
 Creates a socket. More...
 
- Protected Attributes inherited from osl::Socket
oslSocket m_handle
 

Detailed Description

A connectionless socket to send and receive datagrams.

Constructor & Destructor Documentation

osl::DatagramSocket::DatagramSocket ( oslAddrFamily  Family = osl_Socket_FamilyInet,
oslProtocol  Protocol = osl_Socket_ProtocolIp,
oslSocketType  Type = osl_Socket_TypeDgram 
)
inline

Creates a datagram socket.

Parameters
Familythe Family of the socket (Inet by default)
Protocolthe Protocon of the socket (IP by default)
Typeis sock_dgram by default.

Member Function Documentation

sal_Int32 osl::DatagramSocket::recvFrom ( void *  pBuffer,
sal_uInt32  BufferSize,
SocketAddr pSenderAddr = NULL,
oslSocketMsgFlag  Flag = osl_Socket_MsgNormal 
)
inline

Tries to receives BufferSize data from the socket, if no error occurs.

Parameters
pSenderAddr[out] You must provide pointer to a SocketAddr. It will be filled with the address of the datagrams sender. If pSenderAddr is 0, it is ignored.
pBuffer[out] Points to a buffer that will be filled with the received datagram.
BufferSize[in] The size of pBuffer.
Flag[in] Modifier for the call. Valid values are:
  • osl_Socket_MsgNormal
  • osl_Socket_MsgOOB
  • osl_Socket_MsgPeek
  • osl_Socket_MsgDontRoute
  • osl_Socket_MsgMaxIOVLen
Returns
the number of received bytes.
sal_Int32 osl::DatagramSocket::sendTo ( const SocketAddr ReceiverAddr,
const void *  pBuffer,
sal_uInt32  BufferSize,
oslSocketMsgFlag  Flag = osl_Socket_MsgNormal 
)
inline

Tries to send one datagram with BytesToSend size to the given ReceiverAddr.

Since there is only send one packet, the function doesn't care about packet boundaries.

Parameters
ReceiverAddr[in] A SocketAddr that contains the destination address for this send.
pBuffer[in] Points to a buffer that contains the send-data.
BufferSize[in] The number of bytes to send. pBuffer must have at least this size.
Flag[in] Modifier for the call. Valid values are:
  • osl_Socket_MsgNormal
  • osl_Socket_MsgOOB
  • osl_Socket_MsgPeek
  • osl_Socket_MsgDontRoute
  • osl_Socket_MsgMaxIOVLen
Returns
the number of transferred bytes.

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