LibreOffice
LibreOffice 7.4 SDK C/C++ API Reference
Macros
socket.h File Reference
#include "rtl/ustring.h"
#include "osl/time.h"

Go to the source code of this file.

Macros

#define OSL_INADDR_NONE   0xffffffff
 
#define OSL_INVALID_PORT   (-1)
 
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 an 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 oslSocketAddrImpl * oslSocketAddr
 Opaque datatype SocketAddr. More...
 
typedef sal_uInt8 oslSocketIpxNetNumber[4]
 
typedef sal_uInt8 oslSocketIpxNodeNumber[6]
 
typedef struct oslSocketImpl * oslSocket
 
SAL_DLLPUBLIC oslSocket osl_createSocket (oslAddrFamily Family, oslSocketType Type, oslProtocol Protocol)
 Create a socket of the specified Family and Type. 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 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 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...
 
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 host address 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 (NOT the FQDN) More...
 

Macro Definition Documentation

◆ OSL_INADDR_NONE

#define OSL_INADDR_NONE   0xffffffff

◆ OSL_INVALID_PORT

#define OSL_INVALID_PORT   (-1)

Typedef Documentation

◆ oslHostAddr

typedef struct oslHostAddrImpl* oslHostAddr

◆ oslSocket

typedef struct oslSocketImpl* oslSocket

begin section oslSocket

◆ oslSocketAddr

typedef struct oslSocketAddrImpl* oslSocketAddr

Opaque datatype SocketAddr.

begin section types

◆ oslSocketIpxNetNumber

typedef sal_uInt8 oslSocketIpxNetNumber[4]

◆ oslSocketIpxNodeNumber

typedef sal_uInt8 oslSocketIpxNodeNumber[6]

Enumeration Type Documentation

◆ oslAddrFamily

Represents the address-family of a socket.

Enumerator
osl_Socket_FamilyInet 

IP (AF_INET)

osl_Socket_FamilyIpx 

Novell IPX/SPX (AF_IPX)

osl_Socket_FamilyInvalid 

always last entry in enum!

osl_Socket_Family_FORCE_EQUAL_SIZE 

◆ oslProtocol

represent a specific protocol within an address-family

Enumerator
osl_Socket_ProtocolIp 

for all af_inet

osl_Socket_ProtocolIpx 

af_ipx datagram sockets (IPX)

osl_Socket_ProtocolSpx 

af_ipx seqpacket or stream for SPX

osl_Socket_ProtocolSpxII 

af_ipx seqpacket or stream for SPX II

osl_Socket_ProtocolInvalid 

always last entry in enum

osl_Socket_Protocol_FORCE_EQUAL_SIZE 

◆ oslSocketDirection

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 

always last entry in enum

osl_Socket_Dir_FORCE_EQUAL_SIZE 

◆ oslSocketError

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

Enumerator
osl_Socket_E_None 

no error

osl_Socket_E_NotSocket 

Socket operation on non-socket

osl_Socket_E_DestAddrReq 

Destination address required

osl_Socket_E_MsgSize 

Message too long

osl_Socket_E_Prototype 

Protocol wrong type for socket

osl_Socket_E_NoProtocol 

Protocol not available

osl_Socket_E_ProtocolNoSupport 

Protocol not supported

osl_Socket_E_TypeNoSupport 

Socket type not supported

osl_Socket_E_OpNotSupport 

Operation not supported on socket

osl_Socket_E_PfNoSupport 

Protocol family not supported

osl_Socket_E_AfNoSupport 

Address family not supported by
protocol family

osl_Socket_E_AddrInUse 

Address already in use

osl_Socket_E_AddrNotAvail 

Can't assign requested address

osl_Socket_E_NetDown 

Network is down

osl_Socket_E_NetUnreachable 

Network is unreachable

osl_Socket_E_NetReset 

Network dropped connection because of reset

osl_Socket_E_ConnAborted 

Software caused connection abort

osl_Socket_E_ConnReset 

Connection reset by peer

osl_Socket_E_NoBufferSpace 

No buffer space available

osl_Socket_E_IsConnected 

Socket is already connected

osl_Socket_E_NotConnected 

Socket is not connected

osl_Socket_E_Shutdown 

Can't send after socket shutdown

osl_Socket_E_TooManyRefs 

Too many references: can't splice

osl_Socket_E_TimedOut 

Connection timed out

osl_Socket_E_ConnRefused 

Connection refused

osl_Socket_E_HostDown 

Host is down

osl_Socket_E_HostUnreachable 

No route to host

osl_Socket_E_WouldBlock 

call would block on non-blocking socket

osl_Socket_E_Already 

operation already in progress

osl_Socket_E_InProgress 

operation now in progress

osl_Socket_E_InvalidError 

unmapped error: always last entry in enum

osl_Socket_E_FORCE_EQUAL_SIZE 

◆ oslSocketMsgFlag

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 

always last entry in enum

osl_Socket_Msg_FORCE_EQUAL_SIZE 

◆ oslSocketOption

Represents socket-options.

Enumerator
osl_Socket_OptionDebug 

record debugging info

osl_Socket_OptionAcceptConn 

listen for connection

osl_Socket_OptionReuseAddr 

bind to address already in use

osl_Socket_OptionKeepAlive 

use keep-alive

osl_Socket_OptionDontRoute 

do not route packet, send direct to interface addresses

osl_Socket_OptionBroadcast 

send broadcast message

osl_Socket_OptionUseLoopback 

socket receives copy of everything sent on the socket

osl_Socket_OptionLinger 

don't immediately close - "linger" a while to allow for graceful connection closure

osl_Socket_OptionOOBinLine 

out-of-band (OOB) data placed in normal input queue (i.e. OOB inline)

osl_Socket_OptionSndBuf 

send buffer

osl_Socket_OptionRcvBuf 

receive buffer

osl_Socket_OptionSndLowat 

send "low-water" mark - amount of available space in send buffer for select() to return "writable"

osl_Socket_OptionRcvLowat 

receive "low-water" mark - amount of available space in receive buffer for select() to receive "readable"

osl_Socket_OptionSndTimeo 

send timeout

osl_Socket_OptionRcvTimeo 

receive timeout

osl_Socket_OptionError 

socket error

osl_Socket_OptionType 

returns socket type (e.g. datagram, stream).

osl_Socket_OptionTcpNoDelay 

disable TCP Nagle algorithm

osl_Socket_OptionInvalid 

always last entry in enum

osl_Socket_Option_FORCE_EQUAL_SIZE 

◆ oslSocketOptionLevel

Represents the different socket-option levels.

Enumerator
osl_Socket_LevelSocket 
osl_Socket_LevelTcp 
osl_Socket_LevelInvalid 

always last entry in enum

osl_Socket_Level_FORCE_EQUAL_SIZE 

◆ oslSocketResult

Common return codes of socket related functions.

Enumerator
osl_Socket_Ok 

successful completion

osl_Socket_Error 

error occurred, check osl_getLastSocketError() for details

osl_Socket_TimedOut 

blocking operation timed out

osl_Socket_Interrupted 

blocking operation was interrupted

osl_Socket_InProgress 

nonblocking operation is in progress

osl_Socket_FORCE_EQUAL_SIZE 

◆ oslSocketType

Represents the type of a socket.

Enumerator
osl_Socket_TypeStream 

stream socket

osl_Socket_TypeDgram 

datagram socket

osl_Socket_TypeRaw 

raw socket

osl_Socket_TypeRdm 

connectionless, message-oriented, reliably delivered message (RDM) sockets

osl_Socket_TypeSeqPacket 

connection-oriented and reliable two-way transport of ordered byte streams

osl_Socket_TypeInvalid 

always last entry in enum

osl_Socket_Type_FORCE_EQUAL_SIZE 

Function Documentation

◆ osl_acceptConnectionOnSocket()

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.
Return values
0if the accept-call failed, otherwise you get a socket representing the new connection.

◆ osl_acquireSocket()

SAL_DLLPUBLIC void osl_acquireSocket ( oslSocket  Socket)

increases the refcount of the socket handle by one

◆ osl_bindAddrToSocket()

SAL_DLLPUBLIC sal_Bool osl_bindAddrToSocket ( oslSocket  Socket,
oslSocketAddr  Addr 
)

Binds the given address to the socket.

Parameters
[in]Socket
[in]Addr
Return values
sal_Falseif the bind failed
sal_Trueif bind is successful
See also
osl_getLastSocketError()

◆ osl_closeSocket()

SAL_DLLPUBLIC void osl_closeSocket ( oslSocket  Socket)

Closes the socket terminating any ongoing dataflow.

Parameters
[in]SocketThe socket to close.

◆ osl_connectSocketTo()

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.
Return values
osl_Socket_Okon successful connection,
osl_Socket_TimedOutif operation timed out,
osl_Socket_Interruptedif operation was interrupted
osl_Socket_Errorif the connection failed.

◆ osl_copyHostAddr()

SAL_DLLPUBLIC oslHostAddr osl_copyHostAddr ( const oslHostAddr  Addr)

Create a copy of the given Addr.

Returns
The copied address or 0 upon failure.

◆ osl_copySocketAddr()

SAL_DLLPUBLIC oslSocketAddr osl_copySocketAddr ( oslSocketAddr  Addr)

Creates a new SocketAddress and fills it from Addr.

◆ osl_createEmptySocketAddr()

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.

◆ osl_createHostAddr()

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.

◆ osl_createHostAddrByAddr()

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.

◆ osl_createHostAddrByName()

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.

◆ osl_createInetBroadcastAddr()

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.
Return values
0if address could not be created.

◆ osl_createInetSocketAddr()

SAL_DLLPUBLIC oslSocketAddr osl_createInetSocketAddr ( rtl_uString *  strDottedAddr,
sal_Int32  Port 
)

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

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

Parameters
[in]strDottedAddrString with dotted address.
[in]Portportnumber in host byte order.
Return values
0if address could not be created.

◆ osl_createSocket()

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.

◆ osl_destroyHostAddr()

SAL_DLLPUBLIC void osl_destroyHostAddr ( oslHostAddr  Addr)

Frees all resources allocated by Addr.

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

◆ osl_destroySocketAddr()

SAL_DLLPUBLIC void osl_destroySocketAddr ( oslSocketAddr  Addr)

Frees all resources allocated by Addr.

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

◆ osl_enableNonBlockingMode()

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.
Return values
sal_Trueif mode could be changed.

◆ osl_getAddrOfSocketAddr()

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 byte order. *ppByteSeq may be 0 in case of an invalid socket handle.
Return values
osl_Socket_Ok
osl_Socket_Error

◆ osl_getDottedInetAddrOfSocketAddr()

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.
Return values
Ifthe address is invalid or not of type osl_Socket_FamilyInet, it returns 0.
osl_Socket_Ok
osl_Socket_Error

◆ osl_getFamilyOfSocketAddr()

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.

◆ osl_getHostnameOfHostAddr()

SAL_DLLPUBLIC void osl_getHostnameOfHostAddr ( const oslHostAddr  Addr,
rtl_uString **  strHostname 
)

Get the hostname member of Addr.

Returns
The hostname or 0 upon failure.

◆ osl_getHostnameOfSocketAddr()

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.

◆ osl_getInetPortOfSocketAddr()

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

◆ osl_getLastSocketError()

SAL_DLLPUBLIC oslSocketError osl_getLastSocketError ( oslSocket  Socket)

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

Return values
osl_Socket_E_NONEif no error occurred
osl_invalid_SocketErrorif an unknown (unmapped) error occurred, otherwise an enum describing the error.

◆ osl_getLastSocketErrorDescription()

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.

◆ osl_getLocalAddrOfSocket()

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.

◆ osl_getLocalHostname()

SAL_DLLPUBLIC oslSocketResult osl_getLocalHostname ( rtl_uString **  strLocalHostname)

Retrieve this machines hostname (NOT the FQDN)

Parameters
strLocalHostnameout-parameter. The string that receives the local host name.
Return values
sal_Trueupon success
sal_False

◆ osl_getPeerAddrOfSocket()

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.

Return values
0if socket-address could not be created, otherwise you get the created Socket-Address.

◆ osl_getServicePort()

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").

Return values
OSL_INVALID_PORTif no appropriate entry was found, otherwise the port-number.

◆ osl_getSocketAddrOfHostAddr()

SAL_DLLPUBLIC oslSocketAddr osl_getSocketAddrOfHostAddr ( const oslHostAddr  Addr)

Get the socket address member of Addr.

Returns
The socket address or 0 upon failure.

◆ osl_getSocketOption()

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
Parameters
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()

◆ osl_getSocketType()

SAL_DLLPUBLIC oslSocketType osl_getSocketType ( oslSocket  Socket)

Queries the socket for its type.

Parameters
[in]SocketThe socket to query.
Return values
osl_Socket_TypeStream
osl_Socket_TypeDgram
osl_Socket_TypeRaw
osl_Socket_TypeRdm
osl_Socket_TypeSeqPacket
osl_invalid_SocketTypeif an error occurred

◆ osl_isEqualSocketAddr()

SAL_DLLPUBLIC sal_Bool osl_isEqualSocketAddr ( oslSocketAddr  Addr1,
oslSocketAddr  Addr2 
)

Compares the values of two SocketAddresses.

Return values
sal_Trueif both addresses denote the same socket address.
sal_Falseif both addresses do not denote the same socket address.

◆ osl_isExceptionPending()

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.

Parameters
Socketthe Socket to perform the operation on.
pTimeoutif NULL, the operation will block without a timeout.
Return values
sal_Trueif OOB-request operations (recv with appropriate flags) on the Socket will NOT block
sal_Falseif it would block or if an error occurred.

◆ osl_isNonBlockingMode()

SAL_DLLPUBLIC sal_Bool osl_isNonBlockingMode ( oslSocket  Socket)

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

Parameters
SocketQuery mode for this socket.
Return values
Trueif non-blocking-mode is enabled.

◆ osl_isReceiveReady()

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.

Parameters
Socketthe Socket to perform the operation on.
pTimeoutif NULL, the operation will block without a timeout.
Return values
sal_Trueif read operations (recv, recvFrom, accept) on the Socket will NOT block;
sal_Falseif it would block or if an error occurred.

◆ osl_isSendReady()

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.

Parameters
Socketthe Socket to perform the operation on.
pTimeoutif NULL, the operation will block without a timeout. Otherwise the time define by timeout value.
Return values
sal_Trueif send operations (send, sendTo) on the Socket will NOT block
sal_Falseif it would block or if an error occurred.

◆ osl_listenOnSocket()

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).
Return values
sal_Falseif the listen failed.

◆ osl_readSocket()

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.

◆ osl_receiveFromSocket()

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.

◆ osl_receiveSocket()

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.

◆ osl_releaseSocket()

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.

◆ osl_resolveHostname()

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.

◆ osl_sendSocket()

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.

◆ osl_sendToSocket()

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.
[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.

◆ osl_setAddrOfSocketAddr()

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.

◆ osl_setInetPortOfSocketAddr()

SAL_DLLPUBLIC sal_Bool osl_setInetPortOfSocketAddr ( oslSocketAddr  Addr,
sal_Int32  Port 
)

Sets the Port of Addr.

Parameters
[in]Addrthe SocketAddr to perform the operation on.
[in]Portis expected in host byte-order.
Return values
sal_Falseif Addr is not an inet-addr.

◆ osl_setSocketOption()

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.
Return values
Trueif the option could be changed.

◆ osl_shutdownSocket()

SAL_DLLPUBLIC sal_Bool osl_shutdownSocket ( oslSocket  Socket,
oslSocketDirection  Direction 
)

Shuts down communication on a connected socket.

Parameters
[in]Socketthe Socket to perform the operation on.
[in]DirectionDirection denotes 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.
Return values
sal_Trueif the socket could be closed down.

◆ osl_writeSocket()

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.