LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Typedefs | Enumerations
socket.h File Reference
#include <rtl/ustring.h>
#include <rtl/byteseq.h>
#include <osl/time.h>
#include <rtl/tencinfo.h>

Go to the source code of this file.

Macros

#define OSL_INADDR_NONE   0xffffffff
 
#define OSL_INVALID_PORT   (-1)
 

Typedefs

typedef struct oslSocketAddrImpl * oslSocketAddr
 Opaque datatype SocketAddr. More...
 
typedef sal_uInt8 oslSocketIpxNetNumber [4]
 
typedef sal_uInt8 oslSocketIpxNodeNumber [6]
 

Enumerations

enum  oslAddrFamily { osl_Socket_FamilyInet, osl_Socket_FamilyIpx, osl_Socket_FamilyInvalid, osl_Socket_Family_FORCE_EQUAL_SIZE = SAL_MAX_ENUM }
 Represents the address-family of a socket. More...
 
enum  oslProtocol {
  osl_Socket_ProtocolIp, osl_Socket_ProtocolIpx, osl_Socket_ProtocolSpx, osl_Socket_ProtocolSpxII,
  osl_Socket_ProtocolInvalid, osl_Socket_Protocol_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 represent a specific protocol within a address-family More...
 
enum  oslSocketType {
  osl_Socket_TypeStream, osl_Socket_TypeDgram, osl_Socket_TypeRaw, osl_Socket_TypeRdm,
  osl_Socket_TypeSeqPacket, osl_Socket_TypeInvalid, osl_Socket_Type_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Represents the type of a socket. More...
 
enum  oslSocketOption {
  osl_Socket_OptionDebug, osl_Socket_OptionAcceptConn, osl_Socket_OptionReuseAddr, osl_Socket_OptionKeepAlive,
  osl_Socket_OptionDontRoute, osl_Socket_OptionBroadcast, osl_Socket_OptionUseLoopback, osl_Socket_OptionLinger,
  osl_Socket_OptionOOBinLine, osl_Socket_OptionSndBuf, osl_Socket_OptionRcvBuf, osl_Socket_OptionSndLowat,
  osl_Socket_OptionRcvLowat, osl_Socket_OptionSndTimeo, osl_Socket_OptionRcvTimeo, osl_Socket_OptionError,
  osl_Socket_OptionType, osl_Socket_OptionTcpNoDelay, osl_Socket_OptionInvalid, osl_Socket_Option_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Represents socket-options. More...
 
enum  oslSocketOptionLevel { osl_Socket_LevelSocket, osl_Socket_LevelTcp, osl_Socket_LevelInvalid, osl_Socket_Level_FORCE_EQUAL_SIZE = SAL_MAX_ENUM }
 Represents the different socket-option levels. More...
 
enum  oslSocketMsgFlag {
  osl_Socket_MsgNormal, osl_Socket_MsgOOB, osl_Socket_MsgPeek, osl_Socket_MsgDontRoute,
  osl_Socket_MsgMaxIOVLen, osl_Socket_MsgInvalid, osl_Socket_Msg_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Represents flags to be used with send/recv-calls. More...
 
enum  oslSocketDirection {
  osl_Socket_DirRead, osl_Socket_DirWrite, osl_Socket_DirReadWrite, osl_Socket_DirInvalid,
  osl_Socket_Dir_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Used by shutdown to denote which end of the socket to "close". More...
 
enum  oslSocketError {
  osl_Socket_E_None, osl_Socket_E_NotSocket, osl_Socket_E_DestAddrReq, osl_Socket_E_MsgSize,
  osl_Socket_E_Prototype, osl_Socket_E_NoProtocol, osl_Socket_E_ProtocolNoSupport, osl_Socket_E_TypeNoSupport,
  osl_Socket_E_OpNotSupport, osl_Socket_E_PfNoSupport, osl_Socket_E_AfNoSupport, osl_Socket_E_AddrInUse,
  osl_Socket_E_AddrNotAvail, osl_Socket_E_NetDown, osl_Socket_E_NetUnreachable, osl_Socket_E_NetReset,
  osl_Socket_E_ConnAborted, osl_Socket_E_ConnReset, osl_Socket_E_NoBufferSpace, osl_Socket_E_IsConnected,
  osl_Socket_E_NotConnected, osl_Socket_E_Shutdown, osl_Socket_E_TooManyRefs, osl_Socket_E_TimedOut,
  osl_Socket_E_ConnRefused, osl_Socket_E_HostDown, osl_Socket_E_HostUnreachable, osl_Socket_E_WouldBlock,
  osl_Socket_E_Already, osl_Socket_E_InProgress, osl_Socket_E_InvalidError, osl_Socket_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Describes the various error socket error conditions, which may occur. More...
 
enum  oslSocketResult {
  osl_Socket_Ok, osl_Socket_Error, osl_Socket_TimedOut, osl_Socket_Interrupted,
  osl_Socket_InProgress, osl_Socket_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Common return codes of socket related functions. More...
 
typedef struct oslHostAddrImpl * oslHostAddr
 
SAL_DLLPUBLIC oslSocketAddr osl_createEmptySocketAddr (oslAddrFamily Family)
 Creates a socket-address for the given family. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_copySocketAddr (oslSocketAddr Addr)
 Creates a new SocketAddress and fills it from Addr. More...
 
SAL_DLLPUBLIC sal_Bool osl_isEqualSocketAddr (oslSocketAddr Addr1, oslSocketAddr Addr2)
 Compares the values of two SocketAddresses. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_resolveHostname (rtl_uString *strHostname)
 Uses the systems name-service interface to find an address for strHostname. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_createInetBroadcastAddr (rtl_uString *strDottedAddr, sal_Int32 Port)
 Create an internet address usable for sending broadcast datagrams. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_createInetSocketAddr (rtl_uString *strDottedAddr, sal_Int32 Port)
 Create an internet-address, consisting of hostaddress and port. More...
 
SAL_DLLPUBLIC void osl_destroySocketAddr (oslSocketAddr Addr)
 Frees all resources allocated by Addr. More...
 
SAL_DLLPUBLIC sal_Int32 osl_getServicePort (rtl_uString *strServicename, rtl_uString *strProtocol)
 Looks up the port-number designated to the specified service/protocol-pair. More...
 
SAL_DLLPUBLIC oslAddrFamily osl_getFamilyOfSocketAddr (oslSocketAddr Addr)
 Retrieves the address-family from the Addr. More...
 
SAL_DLLPUBLIC sal_Int32 osl_getInetPortOfSocketAddr (oslSocketAddr Addr)
 Retrieves the internet port-number of Addr. More...
 
SAL_DLLPUBLIC sal_Bool osl_setInetPortOfSocketAddr (oslSocketAddr Addr, sal_Int32 Port)
 Sets the Port of Addr. More...
 
SAL_DLLPUBLIC oslSocketResult osl_getHostnameOfSocketAddr (oslSocketAddr Addr, rtl_uString **strHostname)
 Returns the hostname represented by Addr. More...
 
SAL_DLLPUBLIC oslSocketResult osl_getDottedInetAddrOfSocketAddr (oslSocketAddr Addr, rtl_uString **strDottedInetAddr)
 Gets the address in dotted decimal format. More...
 
SAL_DLLPUBLIC oslSocketResult osl_setAddrOfSocketAddr (oslSocketAddr Addr, sal_Sequence *pByteSeq)
 Sets the addr field in the struct sockaddr with pByteSeq. More...
 
SAL_DLLPUBLIC oslSocketResult osl_getAddrOfSocketAddr (oslSocketAddr Addr, sal_Sequence **ppByteSeq)
 Returns the addr field in the struct sockaddr. More...
 
SAL_DLLPUBLIC oslHostAddr osl_createHostAddr (rtl_uString *strHostname, const oslSocketAddr Addr)
 Create an oslHostAddr from given hostname and socket address. More...
 
SAL_DLLPUBLIC oslHostAddr osl_createHostAddrByName (rtl_uString *strHostname)
 Create an oslHostAddr by resolving the given strHostname. More...
 
SAL_DLLPUBLIC oslHostAddr osl_createHostAddrByAddr (const oslSocketAddr Addr)
 Create an oslHostAddr by reverse resolution of the given Addr. More...
 
SAL_DLLPUBLIC oslHostAddr osl_copyHostAddr (const oslHostAddr Addr)
 Create a copy of the given Addr. More...
 
SAL_DLLPUBLIC void osl_destroyHostAddr (oslHostAddr Addr)
 Frees all resources allocated by Addr. More...
 
SAL_DLLPUBLIC void osl_getHostnameOfHostAddr (const oslHostAddr Addr, rtl_uString **strHostname)
 Get the hostname member of Addr. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_getSocketAddrOfHostAddr (const oslHostAddr Addr)
 Get the socket address member of Addr. More...
 
SAL_DLLPUBLIC oslSocketResult osl_getLocalHostname (rtl_uString **strLocalHostname)
 Retrieve this machines hostname. More...
 
typedef struct oslSocketImpl * oslSocket
 
typedef struct oslSocketSetImpl * oslSocketSet
 Type for the representation of socket sets. More...
 
SAL_DLLPUBLIC void osl_acquireSocket (oslSocket Socket)
 increases the refcount of the socket handle by one More...
 
SAL_DLLPUBLIC void osl_releaseSocket (oslSocket Socket)
 decreases the refcount of the socket handle by one. More...
 
SAL_DLLPUBLIC oslSocket osl_createSocket (oslAddrFamily Family, oslSocketType Type, oslProtocol Protocol)
 Create a socket of the specified Family and Type. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_getLocalAddrOfSocket (oslSocket Socket)
 Retrieves the Address of the local end of the socket. More...
 
SAL_DLLPUBLIC oslSocketAddr osl_getPeerAddrOfSocket (oslSocket Socket)
 Retrieves the Address of the remote end of the socket. More...
 
SAL_DLLPUBLIC sal_Bool osl_bindAddrToSocket (oslSocket Socket, oslSocketAddr Addr)
 Binds the given address to the socket. More...
 
SAL_DLLPUBLIC oslSocketResult osl_connectSocketTo (oslSocket Socket, oslSocketAddr Addr, const TimeValue *pTimeout)
 Connects the socket to the given address. More...
 
SAL_DLLPUBLIC sal_Bool osl_listenOnSocket (oslSocket Socket, sal_Int32 MaxPendingConnections)
 Prepares the socket to act as an acceptor of incoming connections. More...
 
SAL_DLLPUBLIC oslSocket osl_acceptConnectionOnSocket (oslSocket Socket, oslSocketAddr *pAddr)
 Waits for an ingoing connection on the socket. More...
 
SAL_DLLPUBLIC sal_Int32 osl_receiveSocket (oslSocket Socket, void *pBuffer, sal_uInt32 BytesToRead, oslSocketMsgFlag Flag)
 Tries to receive BytesToRead data from the connected socket, if no error occurs. More...
 
SAL_DLLPUBLIC sal_Int32 osl_receiveFromSocket (oslSocket Socket, oslSocketAddr SenderAddr, void *pBuffer, sal_uInt32 BufferSize, oslSocketMsgFlag Flag)
 Tries to receives BufferSize data from the (usually unconnected) (datagram-)socket, if no error occurs. More...
 
SAL_DLLPUBLIC sal_Int32 osl_sendSocket (oslSocket Socket, const void *pBuffer, sal_uInt32 BytesToSend, oslSocketMsgFlag Flag)
 Tries to send BytesToSend data from the connected socket, if no error occurs. More...
 
SAL_DLLPUBLIC sal_Int32 osl_sendToSocket (oslSocket Socket, oslSocketAddr ReceiverAddr, const void *pBuffer, sal_uInt32 BytesToSend, oslSocketMsgFlag Flag)
 Tries to send one datagram with BytesToSend data to the given ReceiverAddr via the (implicitly unconnected) datagram-socket. More...
 
SAL_DLLPUBLIC sal_Bool osl_isReceiveReady (oslSocket Socket, const TimeValue *pTimeout)
 Checks if read operations will block. More...
 
SAL_DLLPUBLIC sal_Bool osl_isSendReady (oslSocket Socket, const TimeValue *pTimeout)
 Checks if send operations will block. More...
 
SAL_DLLPUBLIC sal_Bool osl_isExceptionPending (oslSocket Socket, const TimeValue *pTimeout)
 Checks if a request for out-of-band data will block. More...
 
SAL_DLLPUBLIC sal_Bool osl_shutdownSocket (oslSocket Socket, oslSocketDirection Direction)
 Shuts down communication on a connected socket. More...
 
SAL_DLLPUBLIC sal_Int32 osl_getSocketOption (oslSocket Socket, oslSocketOptionLevel Level, oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen)
 Retrieves attributes associated with the socket. More...
 
SAL_DLLPUBLIC sal_Bool osl_setSocketOption (oslSocket Socket, oslSocketOptionLevel Level, oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen)
 Sets the sockets attributes. More...
 
SAL_DLLPUBLIC sal_Bool osl_enableNonBlockingMode (oslSocket Socket, sal_Bool On)
 Enables/disables non-blocking-mode of the socket. More...
 
SAL_DLLPUBLIC sal_Bool osl_isNonBlockingMode (oslSocket Socket)
 Query state of non-blocking-mode of the socket. More...
 
SAL_DLLPUBLIC oslSocketType osl_getSocketType (oslSocket Socket)
 Queries the socket for its type. More...
 
SAL_DLLPUBLIC void osl_getLastSocketErrorDescription (oslSocket Socket, rtl_uString **strError)
 returns a string which describes the last socket error. More...
 
SAL_DLLPUBLIC oslSocketError osl_getLastSocketError (oslSocket Socket)
 returns a constant describing the last error for the socket system. More...
 
SAL_DLLPUBLIC oslSocketSet osl_createSocketSet (void)
 Creates a set of sockets to be used with osl_demultiplexSocketEvents(). More...
 
SAL_DLLPUBLIC void osl_destroySocketSet (oslSocketSet Set)
 Destroys a oslSocketSet. More...
 
SAL_DLLPUBLIC void osl_clearSocketSet (oslSocketSet Set)
 Clears the set from all previously added sockets. More...
 
SAL_DLLPUBLIC void osl_addToSocketSet (oslSocketSet Set, oslSocket Socket)
 Adds a socket to the set. More...
 
SAL_DLLPUBLIC void osl_removeFromSocketSet (oslSocketSet Set, oslSocket Socket)
 Removes a socket from the set. More...
 
SAL_DLLPUBLIC sal_Bool osl_isInSocketSet (oslSocketSet Set, oslSocket Socket)
 Checks if socket is in the set. More...
 
SAL_DLLPUBLIC sal_Int32 osl_demultiplexSocketEvents (oslSocketSet IncomingSet, oslSocketSet OutgoingSet, oslSocketSet OutOfBandSet, const TimeValue *pTimeout)
 Checks multiple sockets for events. More...
 
SAL_DLLPUBLIC void osl_closeSocket (oslSocket Socket)
 Closes the socket terminating any ongoing dataflow. More...
 
SAL_DLLPUBLIC sal_Int32 osl_readSocket (oslSocket Socket, void *pBuffer, sal_Int32 nSize)
 Retrieves n bytes from the stream and copies them into pBuffer. More...
 
SAL_DLLPUBLIC sal_Int32 osl_writeSocket (oslSocket Socket, const void *pBuffer, sal_Int32 nSize)
 Writes n bytes from pBuffer to the stream. More...
 

Macro Definition Documentation

#define OSL_INADDR_NONE   0xffffffff
#define OSL_INVALID_PORT   (-1)

Typedef Documentation

typedef struct oslHostAddrImpl* oslHostAddr
typedef struct oslSocketImpl* oslSocket

begin section oslSocket

typedef struct oslSocketAddrImpl* oslSocketAddr

Opaque datatype SocketAddr.

typedef sal_uInt8 oslSocketIpxNetNumber[4]
typedef sal_uInt8 oslSocketIpxNodeNumber[6]
typedef struct oslSocketSetImpl* oslSocketSet

Type for the representation of socket sets.

Enumeration Type Documentation

Represents the address-family of a socket.

Enumerator
osl_Socket_FamilyInet 
osl_Socket_FamilyIpx 
osl_Socket_FamilyInvalid 
osl_Socket_Family_FORCE_EQUAL_SIZE 

represent a specific protocol within a address-family

Enumerator
osl_Socket_ProtocolIp 
osl_Socket_ProtocolIpx 
osl_Socket_ProtocolSpx 
osl_Socket_ProtocolSpxII 
osl_Socket_ProtocolInvalid 
osl_Socket_Protocol_FORCE_EQUAL_SIZE 

Used by shutdown to denote which end of the socket to "close".

Enumerator
osl_Socket_DirRead 
osl_Socket_DirWrite 
osl_Socket_DirReadWrite 
osl_Socket_DirInvalid 
osl_Socket_Dir_FORCE_EQUAL_SIZE 

Describes the various error socket error conditions, which may occur.

Enumerator
osl_Socket_E_None 
osl_Socket_E_NotSocket 
osl_Socket_E_DestAddrReq 
osl_Socket_E_MsgSize 
osl_Socket_E_Prototype 
osl_Socket_E_NoProtocol 
osl_Socket_E_ProtocolNoSupport 
osl_Socket_E_TypeNoSupport 
osl_Socket_E_OpNotSupport 
osl_Socket_E_PfNoSupport 
osl_Socket_E_AfNoSupport 
osl_Socket_E_AddrInUse 
osl_Socket_E_AddrNotAvail 
osl_Socket_E_NetDown 
osl_Socket_E_NetUnreachable 
osl_Socket_E_NetReset 
osl_Socket_E_ConnAborted 
osl_Socket_E_ConnReset 
osl_Socket_E_NoBufferSpace 
osl_Socket_E_IsConnected 
osl_Socket_E_NotConnected 
osl_Socket_E_Shutdown 
osl_Socket_E_TooManyRefs 
osl_Socket_E_TimedOut 
osl_Socket_E_ConnRefused 
osl_Socket_E_HostDown 
osl_Socket_E_HostUnreachable 
osl_Socket_E_WouldBlock 
osl_Socket_E_Already 
osl_Socket_E_InProgress 
osl_Socket_E_InvalidError 
osl_Socket_E_FORCE_EQUAL_SIZE 

Represents flags to be used with send/recv-calls.

Enumerator
osl_Socket_MsgNormal 
osl_Socket_MsgOOB 
osl_Socket_MsgPeek 
osl_Socket_MsgDontRoute 
osl_Socket_MsgMaxIOVLen 
osl_Socket_MsgInvalid 
osl_Socket_Msg_FORCE_EQUAL_SIZE 

Represents socket-options.

Enumerator
osl_Socket_OptionDebug 
osl_Socket_OptionAcceptConn 
osl_Socket_OptionReuseAddr 
osl_Socket_OptionKeepAlive 
osl_Socket_OptionDontRoute 
osl_Socket_OptionBroadcast 
osl_Socket_OptionUseLoopback 
osl_Socket_OptionLinger 
osl_Socket_OptionOOBinLine 
osl_Socket_OptionSndBuf 
osl_Socket_OptionRcvBuf 
osl_Socket_OptionSndLowat 
osl_Socket_OptionRcvLowat 
osl_Socket_OptionSndTimeo 
osl_Socket_OptionRcvTimeo 
osl_Socket_OptionError 
osl_Socket_OptionType 
osl_Socket_OptionTcpNoDelay 
osl_Socket_OptionInvalid 
osl_Socket_Option_FORCE_EQUAL_SIZE 

Represents the different socket-option levels.

Enumerator
osl_Socket_LevelSocket 
osl_Socket_LevelTcp 
osl_Socket_LevelInvalid 
osl_Socket_Level_FORCE_EQUAL_SIZE 

Common return codes of socket related functions.

Enumerator
osl_Socket_Ok 
osl_Socket_Error 
osl_Socket_TimedOut 
osl_Socket_Interrupted 
osl_Socket_InProgress 
osl_Socket_FORCE_EQUAL_SIZE 

Represents the type of a socket.

Enumerator
osl_Socket_TypeStream 
osl_Socket_TypeDgram 
osl_Socket_TypeRaw 
osl_Socket_TypeRdm 
osl_Socket_TypeSeqPacket 
osl_Socket_TypeInvalid 
osl_Socket_Type_FORCE_EQUAL_SIZE 

Function Documentation

SAL_DLLPUBLIC oslSocket osl_acceptConnectionOnSocket ( oslSocket  Socket,
oslSocketAddr pAddr 
)

Waits for an ingoing connection on the socket.

This call blocks if there is no incoming connection present.

Parameters
[in]SocketThe socket to accept the connection on.
[in]pAddrif pAddr is != 0, the peers address is returned.
Returns
0 if the accept-call failed, otherwise you get a socket representing the new connection.
SAL_DLLPUBLIC void osl_acquireSocket ( oslSocket  Socket)

increases the refcount of the socket handle by one

SAL_DLLPUBLIC void osl_addToSocketSet ( oslSocketSet  Set,
oslSocket  Socket 
)

Adds a socket to the set.

Parameters
Setthe set were the socket is added.
Socketthe socket to be added.
SAL_DLLPUBLIC sal_Bool osl_bindAddrToSocket ( oslSocket  Socket,
oslSocketAddr  Addr 
)

Binds the given address to the socket.

Parameters
[in]Socket
[in]Addr
Returns
sal_False if the bind failed, sal_True if successful.
See Also
osl_getLastSocketError()
SAL_DLLPUBLIC void osl_clearSocketSet ( oslSocketSet  Set)

Clears the set from all previously added sockets.

Parameters
Setthe set to be cleared.
SAL_DLLPUBLIC void osl_closeSocket ( oslSocket  Socket)

Closes the socket terminating any ongoing dataflow.

Parameters
[in]SocketThe socket to close.
SAL_DLLPUBLIC oslSocketResult osl_connectSocketTo ( oslSocket  Socket,
oslSocketAddr  Addr,
const TimeValue pTimeout 
)

Connects the socket to the given address.

Parameters
[in]Socketa bound socket.
[in]Addrthe peer address.
pTimeoutTimeout value or NULL for blocking.
Returns
osl_Socket_Ok on successful connection, osl_Socket_TimedOut if operation timed out, osl_Socket_Interrupted if operation was interrupted osl_Socket_Error if the connection failed.
SAL_DLLPUBLIC oslHostAddr osl_copyHostAddr ( const oslHostAddr  Addr)

Create a copy of the given Addr.

Returns
The copied address or 0 upon failure.
SAL_DLLPUBLIC oslSocketAddr osl_copySocketAddr ( oslSocketAddr  Addr)

Creates a new SocketAddress and fills it from Addr.

SAL_DLLPUBLIC oslSocketAddr osl_createEmptySocketAddr ( oslAddrFamily  Family)

Creates a socket-address for the given family.

begin section oslSocketAddr

Parameters
FamilyIf family == osl_Socket_FamilyInet the address is set to INADDR_ANY port 0.
Returns
0 if address could not be created.
SAL_DLLPUBLIC oslHostAddr osl_createHostAddr ( rtl_uString *  strHostname,
const oslSocketAddr  Addr 
)

Create an oslHostAddr from given hostname and socket address.

Parameters
[in]strHostnameThe hostname to be stored.
[in]AddrThe socket address to be stored.
Returns
The created address or 0 upon failure.
SAL_DLLPUBLIC oslHostAddr osl_createHostAddrByAddr ( const oslSocketAddr  Addr)

Create an oslHostAddr by reverse resolution of the given Addr.

Successful name resolution should result in the fully qualified domain name (FQDN) and its address as hostname and socket address members of the resulting oslHostAddr.

Parameters
[in]AddrThe socket address to be reverse resolved.
Returns
The resulting address or 0 upon failure.
SAL_DLLPUBLIC oslHostAddr osl_createHostAddrByName ( rtl_uString *  strHostname)

Create an oslHostAddr by resolving the given strHostname.

Successful name resolution should result in the fully qualified domain name (FQDN) and its address as hostname and socket address members of the resulting oslHostAddr.

Parameters
[in]strHostnameThe hostname to be resolved.
Returns
The resulting address or 0 upon failure.
SAL_DLLPUBLIC oslSocketAddr osl_createInetBroadcastAddr ( rtl_uString *  strDottedAddr,
sal_Int32  Port 
)

Create an internet address usable for sending broadcast datagrams.

To limit the broadcast to your subnet, pass your hosts IP address in dotted decimal notation as first argument.

See Also
osl_sendToSocket()
oslSocketAddr
Parameters
[in]strDottedAddrdotted decimal internet address, may be 0.
[in]Portport number in host byte order.
Returns
0 if address could not be created.
SAL_DLLPUBLIC oslSocketAddr osl_createInetSocketAddr ( rtl_uString *  strDottedAddr,
sal_Int32  Port 
)

Create an internet-address, consisting of hostaddress and port.

We interpret strDottedAddr as a dotted-decimal inet-addr (e.g. "141.99.128.50").

Parameters
strDottedAddr[in] String with dotted address.
Port[in] portnumber in host byte order.
Returns
0 if address could not be created.
SAL_DLLPUBLIC oslSocket osl_createSocket ( oslAddrFamily  Family,
oslSocketType  Type,
oslProtocol  Protocol 
)

Create a socket of the specified Family and Type.

The semantic of the Protocol parameter depends on the given family and type.

Returns
0 if socket could not be created, otherwise you get a handle to the allocated socket-datastructure.
SAL_DLLPUBLIC oslSocketSet osl_createSocketSet ( void  )

Creates a set of sockets to be used with osl_demultiplexSocketEvents().

Returns
A oslSocketSet or 0 if creation failed.
SAL_DLLPUBLIC sal_Int32 osl_demultiplexSocketEvents ( oslSocketSet  IncomingSet,
oslSocketSet  OutgoingSet,
oslSocketSet  OutOfBandSet,
const TimeValue pTimeout 
)

Checks multiple sockets for events.

Parameters
IncomingSetChecks the sockets in this set for incoming events (read, accept). If the set is 0, it is just skipped.
OutgoingSetChecks the sockets in this set for outgoing events (write, connect). If the set is 0, it is just skipped.
OutOfBandSetChecks the sockets in this set for out-of-band events. If the set is 0, it is just skipped.
pTimeoutAddress of the number of milliseconds to wait for events. If pTimeout is -1, the call will block until an event or an error occurs.
Returns
-1 on errors, otherwise the number of sockets with pending events. In case of timeout, the number might be 0.
SAL_DLLPUBLIC void osl_destroyHostAddr ( oslHostAddr  Addr)

Frees all resources allocated by Addr.

The handle Addr must not be used after the call anymore.

SAL_DLLPUBLIC void osl_destroySocketAddr ( oslSocketAddr  Addr)

Frees all resources allocated by Addr.

The handle Addr must not be used after the call anymore.

SAL_DLLPUBLIC void osl_destroySocketSet ( oslSocketSet  Set)

Destroys a oslSocketSet.

SAL_DLLPUBLIC sal_Bool osl_enableNonBlockingMode ( oslSocket  Socket,
sal_Bool  On 
)

Enables/disables non-blocking-mode of the socket.

Parameters
SocketChange mode for this socket.
Onsal_True enables non-blocking mode, sal_False disables non-blocking mode.
Returns
sal_True if mode could be changed.
SAL_DLLPUBLIC oslSocketResult osl_getAddrOfSocketAddr ( oslSocketAddr  Addr,
sal_Sequence **  ppByteSeq 
)

Returns the addr field in the struct sockaddr.

Parameters
[in]AddrThe socket address from which to extract the ipaddress.
[out]ppByteSeqAfter the call, *ppByteSeq contains the ipaddress in network byteorder. *ppByteSeq may be 0 in case of an invalid socket handle.
Returns
osl_Socket_Ok or osl_Socket_Error
SAL_DLLPUBLIC oslSocketResult osl_getDottedInetAddrOfSocketAddr ( oslSocketAddr  Addr,
rtl_uString **  strDottedInetAddr 
)

Gets the address in dotted decimal format.

Parameters
[in]AddrThe socket address from which to extract the dotted decimal address.
[out]strDottedInetAddrContains the dotted decimal address (e.g. 141.99.20.34) represented by the address. If the address is invalid or not of type osl_Socket_FamilyInet, it returns 0.
Returns
osl_Socket_Ok or osl_Socket_Error
SAL_DLLPUBLIC oslAddrFamily osl_getFamilyOfSocketAddr ( oslSocketAddr  Addr)

Retrieves the address-family from the Addr.

Returns
the family of the socket-address. In case of an unknown family you get osl_Socket_FamilyInvalid.
SAL_DLLPUBLIC void osl_getHostnameOfHostAddr ( const oslHostAddr  Addr,
rtl_uString **  strHostname 
)

Get the hostname member of Addr.

Returns
The hostname or 0 upon failure.
SAL_DLLPUBLIC oslSocketResult osl_getHostnameOfSocketAddr ( oslSocketAddr  Addr,
rtl_uString **  strHostname 
)

Returns the hostname represented by Addr.

Parameters
[in]AddrThe socket address from which to extract the hostname.
[out]strHostnameThe hostname represented by the address. If there is no hostname to be found, it returns 0.
SAL_DLLPUBLIC sal_Int32 osl_getInetPortOfSocketAddr ( oslSocketAddr  Addr)

Retrieves the internet port-number of Addr.

Returns
the port-number of the address in host-byte order. If Addr is not an address of type osl_Socket_FamilyInet, it returns OSL_INVALID_PORT
SAL_DLLPUBLIC oslSocketError osl_getLastSocketError ( oslSocket  Socket)

returns a constant describing the last error for the socket system.

Returns
osl_Socket_E_NONE if no error occurred, osl_invalid_SocketError if an unknown (unmapped) error occurred, otherwise an enum describing the error.
SAL_DLLPUBLIC void osl_getLastSocketErrorDescription ( oslSocket  Socket,
rtl_uString **  strError 
)

returns a string which describes the last socket error.

Parameters
[in]SocketThe socket to query.
[out]strErrorThe string that receives the error message.
SAL_DLLPUBLIC oslSocketAddr osl_getLocalAddrOfSocket ( oslSocket  Socket)

Retrieves the Address of the local end of the socket.

Note that a socket must be bound or connected before a valid address can be returned.

Returns
0 if socket-address could not be created, otherwise you get the created Socket-Address.
SAL_DLLPUBLIC oslSocketResult osl_getLocalHostname ( rtl_uString **  strLocalHostname)

Retrieve this machines hostname.

May not always be a fully qualified domain name (FQDN).

Parameters
strLocalHostnameout-parameter. The string that receives the local host name.
Returns
sal_True upon success, sal_False otherwise.
SAL_DLLPUBLIC oslSocketAddr osl_getPeerAddrOfSocket ( oslSocket  Socket)

Retrieves the Address of the remote end of the socket.

Note that a socket must be connected before a valid address can be returned.

Returns
0 if socket-address could not be created, otherwise you get the created Socket-Address.
SAL_DLLPUBLIC sal_Int32 osl_getServicePort ( rtl_uString *  strServicename,
rtl_uString *  strProtocol 
)

Looks up the port-number designated to the specified service/protocol-pair.

(e.g. "ftp" "tcp").

Returns
OSL_INVALID_PORT if no appropriate entry was found, otherwise the port-number.
SAL_DLLPUBLIC oslSocketAddr osl_getSocketAddrOfHostAddr ( const oslHostAddr  Addr)

Get the socket address member of Addr.

Returns
The socket address or 0 upon failure.
SAL_DLLPUBLIC sal_Int32 osl_getSocketOption ( oslSocket  Socket,
oslSocketOptionLevel  Level,
oslSocketOption  Option,
void *  pBuffer,
sal_uInt32  BufferLen 
)

Retrieves attributes associated with the socket.

Parameters
Socketis the socket to query.
Levelselects the level for which an option should be queried. Valid values are:
  • osl_sol_socket: Socket Level
  • osl_sol_tcp: Level of Transmission Control Protocol
Optiondenotes the option to query. Valid values (depending on the Level) are:
  • osl_Socket_Option_Debug
    (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.

  • osl_Socket_OptionAcceptConn
  • osl_Socket_OptionReuseAddr
    (sal_Bool) Allows the socket to be bound to an address that is already in use. 1 = multiple bound allowed, 0 = no multiple bounds allowed

  • osl_Socket_OptionKeepAlive
    (sal_Bool) Keepalive packets are sent by the underlying socket. 1 = enabled, 0 = disabled

  • osl_Socket_OptionDontRoute
    (sal_Bool) Do not route: send directly to interface. 1 = do not route , 0 = routing possible

  • osl_Socket_OptionBroadcast
    (sal_Bool) Transmission of broadcast messages are allowed on the socket. 1 = transmission allowed, 0 = transmission disallowed

  • osl_Socket_OptionUseLoopback

  • osl_Socket_OptionLinger
    (sal_Int32) Linger on close if unsent data is present. 0 = linger is off, > 0 = timeout in seconds.

  • osl_Socket_OptionOOBinLine

  • osl_Socket_OptionSndBuf
    (sal_Int32) Size of the send buffer in bytes. Data is sent after SndTimeo or when the buffer is full. This allows faster writing to the socket.

  • osl_Socket_OptionRcvBuf
    (sal_Int32) Size of the receive buffer in bytes. Data is sent after SndTimeo or when the buffer is full. This allows faster writing to the socket and larger packet sizes.

  • osl_Socket_OptionSndLowat

  • osl_Socket_OptionRcvLowat

  • osl_Socket_OptionSndTimeo
    (sal_Int32) Data is sent after this timeout. This allows gathering of data to send larger packages but increases latency times.

  • osl_Socket_OptionRcvTimeo

  • osl_Socket_OptionError
  • osl_Socket_OptionType

  • osl_Socket_OptionTcpNoDelay
    Disables the Nagle algorithm for send coalescing. (Do not collect data until a packet is full, instead send immediately. This increases network traffic but might improve latency-times.) 1 = disables the algorithm, 0 = keeps it enabled.
If not above mentioned otherwise, the options are only valid for level osl_Socket_LevelSocket.
pBufferPointer to a buffer large enough to take the desired attribute-value.
BufferLencontains the length of the Buffer.
Returns
-1 if an error occurred or else the size of the data copied into pBuffer.
See Also
osl_setSocketOption()
SAL_DLLPUBLIC oslSocketType osl_getSocketType ( oslSocket  Socket)

Queries the socket for its type.

Parameters
[in]SocketThe socket to query.
Returns
one of:
  • osl_Socket_TypeStream
  • osl_Socket_TypeDgram
  • osl_Socket_TypeRaw
  • osl_Socket_TypeRdm
  • osl_Socket_TypeSeqPacket
  • osl_invalid_SocketType, if an error occurred
SAL_DLLPUBLIC sal_Bool osl_isEqualSocketAddr ( oslSocketAddr  Addr1,
oslSocketAddr  Addr2 
)

Compares the values of two SocketAddresses.

Returns
sal_True if both addresses denote the same socket address, sal_False otherwise.
SAL_DLLPUBLIC sal_Bool osl_isExceptionPending ( oslSocket  Socket,
const TimeValue pTimeout 
)

Checks if a request for out-of-band data will block.

You can specify a timeout-value in seconds/microseconds that denotes how long the operation will block if the Socket has no pending OOB data.

Returns
sal_True if OOB-request operations (recv with appropriate flags) on the Socket will NOT block; sal_False if it would block or if an error occurred.
Parameters
Socketthe Socket to perfom the operation on.
pTimeoutif NULL, the operation will block without a timeout.
SAL_DLLPUBLIC sal_Bool osl_isInSocketSet ( oslSocketSet  Set,
oslSocket  Socket 
)

Checks if socket is in the set.

Parameters
Setthe set to be checked.
Socketcheck if this socket is in the set.
Returns
sal_True if socket is in the set.
SAL_DLLPUBLIC sal_Bool osl_isNonBlockingMode ( oslSocket  Socket)

Query state of non-blocking-mode of the socket.

Parameters
SocketQuery mode for this socket.
Returns
True if non-blocking-mode is enabled.
SAL_DLLPUBLIC sal_Bool osl_isReceiveReady ( oslSocket  Socket,
const TimeValue pTimeout 
)

Checks if read operations will block.

You can specify a timeout-value in seconds/microseconds that denotes how long the operation will block if the Socket is not ready.

Returns
sal_True if read operations (recv, recvFrom, accept) on the Socket will NOT block; sal_False if it would block or if an error occurred.
Parameters
Socketthe Socket to perfom the operation on.
pTimeoutif NULL, the operation will block without a timeout.
SAL_DLLPUBLIC sal_Bool osl_isSendReady ( oslSocket  Socket,
const TimeValue pTimeout 
)

Checks if send operations will block.

You can specify a timeout-value in seconds/microseconds that denotes how long the operation will block if the Socket is not ready.

Returns
sal_True if send operations (send, sendTo) on the Socket will NOT block; sal_False if it would block or if an error occurred.
Parameters
Socketthe Socket to perfom the operation on.
pTimeoutif NULL, the operation will block without a timeout. Otherwise the time define by timeout value.
SAL_DLLPUBLIC sal_Bool osl_listenOnSocket ( oslSocket  Socket,
sal_Int32  MaxPendingConnections 
)

Prepares the socket to act as an acceptor of incoming connections.

You should call "listen" before you use "accept".

Parameters
[in]SocketThe socket to listen on.
[in]MaxPendingConnectionsdenotes the length of the queue of pending connections for this socket. If MaxPendingConnections is -1, the systems default value will be used (Usually 5).
Returns
sal_False if the listen failed.
SAL_DLLPUBLIC sal_Int32 osl_readSocket ( oslSocket  Socket,
void *  pBuffer,
sal_Int32  nSize 
)

Retrieves n bytes from the stream and copies them into pBuffer.

The function avoids incomplete reads due to packet boundaries.

Parameters
[in]SocketThe socket to read from.
[out]pBufferreceives the read data.
[out]nSizethe number of bytes to read. pBuffer must be large enough to hold the n bytes!
Returns
the number of read bytes. The number will only be smaller than n if an exceptional condition (e.g. connection closed) occurs.
SAL_DLLPUBLIC sal_Int32 osl_receiveFromSocket ( oslSocket  Socket,
oslSocketAddr  SenderAddr,
void *  pBuffer,
sal_uInt32  BufferSize,
oslSocketMsgFlag  Flag 
)

Tries to receives BufferSize data from the (usually unconnected) (datagram-)socket, if no error occurs.

Parameters
[in]SocketA bound socket to be used to listen for a datagram.
[out]SenderAddrA pointer to a created oslSocketAddr handle or to a null handle. After the call, it will contain the constructed oslSocketAddr of the datagrams sender. If pSenderAddr itself is 0, it is ignored.
[out]pBufferPoints to a buffer that will be filled with the received datagram.
[in]BufferSizeThe size of pBuffer.
[in]FlagModifier 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_DLLPUBLIC sal_Int32 osl_receiveSocket ( oslSocket  Socket,
void *  pBuffer,
sal_uInt32  BytesToRead,
oslSocketMsgFlag  Flag 
)

Tries to receive BytesToRead data from the connected socket, if no error occurs.

Note that incomplete recvs due to packet boundaries may occur.

Parameters
[in]SocketA connected socket to be used to listen on.
[out]pBufferPoints to a buffer that will be filled with the received data.
[in]BytesToReadThe number of bytes to read. pBuffer must have at least this size.
[in]FlagModifier 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_DLLPUBLIC void osl_releaseSocket ( oslSocket  Socket)

decreases the refcount of the socket handle by one.

If the refcount drops to zero, the underlying socket handle is destroyed and becomes invalid.

SAL_DLLPUBLIC void osl_removeFromSocketSet ( oslSocketSet  Set,
oslSocket  Socket 
)

Removes a socket from the set.

Parameters
Setthe set were the socket is removed from.
Socketthe socket to be removed.
SAL_DLLPUBLIC oslSocketAddr osl_resolveHostname ( rtl_uString *  strHostname)

Uses the systems name-service interface to find an address for strHostname.

Parameters
[in]strHostnameThe name for which you search for an address.
Returns
The desired address if one could be found, otherwise 0. Don't forget to destroy the address if you don't need it any longer.
SAL_DLLPUBLIC sal_Int32 osl_sendSocket ( oslSocket  Socket,
const void *  pBuffer,
sal_uInt32  BytesToSend,
oslSocketMsgFlag  Flag 
)

Tries to send BytesToSend data from the connected socket, if no error occurs.

Parameters
[in]SocketA connected socket.
[in]pBufferPoints to a buffer that contains the send-data.
[in]BytesToSendThe number of bytes to send. pBuffer must have at least this size.
[in]FlagModifier 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.
SAL_DLLPUBLIC sal_Int32 osl_sendToSocket ( oslSocket  Socket,
oslSocketAddr  ReceiverAddr,
const void *  pBuffer,
sal_uInt32  BytesToSend,
oslSocketMsgFlag  Flag 
)

Tries to send one datagram with BytesToSend data to the given ReceiverAddr via the (implicitly unconnected) datagram-socket.

Since there is only sent one packet, the function sends the data always complete even with incomplete packet boundaries.

Parameters
[in]SocketA bound or unbound socket. Socket will be bound after a successful call.
[in]ReceiverAddrAn initialized oslSocketAddress that contains the destination address for this send.
[in]pBufferPoints to a buffer that contains the send-data.
[in]BytesToSendThe 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.
SAL_DLLPUBLIC oslSocketResult osl_setAddrOfSocketAddr ( oslSocketAddr  Addr,
sal_Sequence pByteSeq 
)

Sets the addr field in the struct sockaddr with pByteSeq.

pByteSeq must be in network byte order.

SAL_DLLPUBLIC sal_Bool osl_setInetPortOfSocketAddr ( oslSocketAddr  Addr,
sal_Int32  Port 
)

Sets the Port of Addr.

Parameters
[in]Addrthe SocketAddr to perfom the operation on.
[in]Portis expected in host byte-order.
Returns
sal_False if Addr is not an inet-addr.
SAL_DLLPUBLIC sal_Bool osl_setSocketOption ( oslSocket  Socket,
oslSocketOptionLevel  Level,
oslSocketOption  Option,
void *  pBuffer,
sal_uInt32  BufferLen 
)

Sets the sockets attributes.

Parameters
Socketis the socket to modify.
Levelselects the level for which an option should be changed. Valid values are:
  • osl_sol_socket: Socket Level
  • osl_sol_tcp: Level of Transmission Control Protocol
Optiondenotes the option to modify. See osl_setSocketOption() for more details.
pBufferPointer to a Buffer which contains the attribute-value.
BufferLencontains the length of the Buffer.
Returns
True if the option could be changed.
SAL_DLLPUBLIC sal_Bool osl_shutdownSocket ( oslSocket  Socket,
oslSocketDirection  Direction 
)

Shuts down communication on a connected socket.

Parameters
[in]Socketthe Socket to perfom the operation on.
[in]Directiondenotes which end of the socket should be closed:
  • osl_Socket_DirRead closes read operations.
  • osl_Socket_DirReadWrite closes write operations.
  • osl_Socket_DirWrite closes read and write operations.
Returns
sal_True if the socket could be closed down.
SAL_DLLPUBLIC sal_Int32 osl_writeSocket ( oslSocket  Socket,
const void *  pBuffer,
sal_Int32  nSize 
)

Writes n bytes from pBuffer to the stream.

The method avoids incomplete writes due to packet boundaries.

Parameters
[out]SocketThe socket to write to.
[in]pBuffercontains the data to be written.
[in]nSizethe number of bytes to write.
Returns
the number of written bytes. The number will only be smaller than nSize if an exceptional condition (e.g. connection closed) occurs.