Overview | Namespace | Class | Index | Help |
Methods of Class Socket
- Socket
- Socket(
oslSocketType Type, oslAddrFamily Family = osl_Socket_FamilyInet, oslProtocol Protocol = osl_Socket_ProtocolIp );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Creates a socket. Note it's protected.
- Parameters
Type Family Protocol
- Socket
- Socket();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Socket
- Socket(
const Socket & socket );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Socket
- Socket(
oslSocket socketHandle );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Socket
- Socket(
oslSocket socketHandle, __sal_NoAcquire noacquire );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- The instance takes over the handle's ownership without acquiring the handle, but releases it within the dtor.
- Parameters
noacquire use SAL_NO_ACQUIRE
- ~Socket
- ~Socket();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Destructor. Releases the underlying handle
- operator=
-
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Assignment operator. If socket was already created, the old one will be discarded.
- operator=
-
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Assignment operator. If socket was already created, the old one will be discarded.
- operator==
-
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Return
sal_True
, when the underlying handle of both Socket instances are identical,sal_False
otherwise.
- operator==
-
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Return
sal_True
, when the underlying handle of both Socket instances are identical,sal_False
otherwise.
- shutdown
- void shutdown(
oslSocketDirection Direction = osl_Socket_DirReadWrite );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Closes a definite or both directions of the bidirectional stream.
- Parameters
Direction - See Also
- osl_shutdownSocket()
- close
- void close();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Description
- Closes a socket. Note that closing a socket is identical to shutdown( osl_Socket_DirReadWrite ), as the operating system distinguish both cases, both functions or offered in this API.
- See Also
- osl_closeSocket()
- getLocalAddr
- void getLocalAddr(
SocketAddr & Addr ) const;
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Retrieves the address of the local interface of this socket.
- Parameters
Addr receives the address.
- See Also
- osl_getLocalAddrOfSocket()
- getLocalPort
- sal_Int32 getLocalPort();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Get the local port of the socket. Usually used after bind().
- Return
- the port number or OSL_INVALID_PORT on errors.
- getLocalHost
- ::rtl::OUString getLocalHost();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Get the hostname for the local interface.
- Return
- the hostname or an empty string ("").
- getPeerAddr
- void getPeerAddr(
SocketAddr & Addr ) const;
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Retrieves the address of the remote host of this socket.
- Parameters
Addr receives the address.
- getPeerPort
- sal_Int32 getPeerPort();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Get the remote port of the socket.
- Return
- the port number or OSL_INVALID_PORT on errors.
- getPeerHost
- ::rtl::OUString getPeerHost();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Get the hostname for the remote interface.
- Return
- the hostname or an empty string ("").
- bind
- sal_Bool bind(
const SocketAddr & LocalInterface );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Binds the socket to the specified (local) interface.
- Parameters
LocalInterface Address of the Interface
- Return
- True if bind was successful.
- isRecvReady
-
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Checks if read operations will block.
- Description
- You can specify a timeout-value in seconds/nanoseconds that denotes how the operation will block if the Socket is not ready.
- Return
sal_True
if read operations (recv, recvFrom, accept) on the Socket will NOT block;sal_False
if it would block or if an error occured.- Parameters
pTimeout if 0, the operation will block without a timeout. Otherwise the specified amout of time.
- isSendReady
-
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Checks if send operations will block.
- Description
- You can specify a timeout-value in seconds/nanoseconds that denotes how the operation will block if the Socket is not ready.
- Return
sal_True
if send operations (send, sendTo) on the Socket will NOT block;sal_False
if it would block or if an error occured.- Parameters
pTimeout if 0, the operation will block without a timeout. Otherwise the specified amout of time.
- isExceptionPending
-
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Checks if a request for out-of-band data will block.
- Description
- You can specify a timeout-value in seconds/nanoseconds that denotes how the operation will block if the Socket has no pending OOB data.
- Return
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 occured.- Parameters
pTimeout if 0, the operation will block without a timeout. Otherwise the specified amout of time.
- getType
- oslSocketType getType();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Queries the socket for its type.
- Return
- one of:
-
osl_Socket_TypeStream
-
osl_Socket_TypeDgram
-
osl_Socket_TypeRaw
-
osl_Socket_TypeRdm
-
osl_Socket_TypeSeqPacket
-
osl_invalid_SocketType
, if an error occured
-
- getOption
- sal_Int32 getOption(
oslSocketOption Option, void * pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level = osl_Socket_LevelSocket ) const;
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Retrieves option-attributes associated with the socket.
- Parameters
Option The attribute 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 = disabledosl_Socket_OptionDontRoute
(sal_Bool) Do not route: send directly to interface. 1 = do not route , 0 = routing possibleosl_Socket_OptionBroadcast
(sal_Bool) Transmission of broadcast messages are allowed on the socket. 1 = transmission allowed, 0 = transmission disallowedosl_Socket_OptionUseLoopback
osl_Socket_OptionLinger
(linger) Linger on close if unsent data is present. linger has two members: l_onoff, l_linger l_onoff = 0 is off, l_onoff > 0 and l_linger= 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 immediatly. This increases network traffic but might improve latency-times.) 1 = disables the algorithm, 0 = keeps it enabled.
osl_Socket_LevelSocket
.pBuffer The Buffer will be filled with the attribute.
BufferSize The size of pBuffer.
Level The option level. Valid values are:
osl_Socket_LevelSocket
: Socket Levelosl_Socket_LevelTcp
: Level of Transmission Control Protocol
-
- Return
- The size of the attribute copied into pBuffer or -1 if an error occured.
- setOption
- sal_Bool setOption(
oslSocketOption Option, void * pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level = osl_Socket_LevelSocket ) const;
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Sets the sockets attributes.
- Parameters
Option denotes the option to modify. Valid values (depending on the Level) are:
- osl_Socket_Option_Debug
- 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
pBuffer Pointer to a Buffer which contains the attribute-value.
BufferSize contains the length of the Buffer.
Level selects the level for which an option should be changed. Valid values are:
- osl_Socket_evel_Socket : Socket Level
- osl_Socket_Level_Tcp : Level of Transmission Control Protocol
- Return
- True if the option could be changed.
- setOption
- sal_Bool setOption(
oslSocketOption option, sal_Int32 nValue );
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Convenience function for setting sal_Bool and sal_Int32 option values.
- See Also
- setOption()
- getOption
- sal_Int32 getOption(
oslSocketOption option ) const;
virtual abstract const volatile template static inline C-linkage NO NO YES NO NO NO YES NO
- Summary
- Convenience function for retrieving sal_Bool and sal_Int32 option values.
- See Also
- setOption()
- enableNonBlockingMode
-
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Enables/disables non-blocking mode of the socket.
- Parameters
bNonBlockingMode If
sal_True
, blocking mode will be switched off Ifsal_False
, the socket will become a blocking socket (which is the default behaviour of a socket).- Return
sal_True
if mode could be set.
- isNonBlockingMode
- sal_Bool isNonBlockingMode();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Query blocking mode of the socket.
- Return
sal_True
if non-blocking mode is set.
- clearError
- void clearError();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- clears the error status
- getError
- oslSocketError getError();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- returns a constant decribing the last error for the socket system.
- Return
- osl_Socket_E_NONE if no error occured, invalid_SocketError if an unknown (unmapped) error occured, otherwise an enum describing the error.
- See Also
- osl_getLastSocketError()
- getErrorAsString
- ::rtl::OUString getErrorAsString();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Builds a string with the last error-message for the socket.
- getHandle
- oslSocket getHandle();
virtual abstract const volatile template static inline C-linkage NO NO NO NO NO NO YES NO
- Summary
- Returns the underlying handle unacquired (The caller must acquire it to keep it).
Top of Page
Copyright © 2012, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.