Language

The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.11
 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.
Parameters
Family
Type
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


~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=
Socket & operator=(
oslSocket socketHandle );

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=
Socket & operator=(
const Socket & sock );

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==
sal_Bool operator==(
const Socket & rSocket ) const;

virtual abstract const volatile template static inline C-linkage
NO NO YES NO NO NO YES NO

Return
true, when the underlying handle of both
Socket references are identical.
false otherwise

operator==
sal_Bool operator==(
const oslSocket socketHandle ) const;

virtual abstract const volatile template static inline C-linkage
NO NO YES NO NO NO YES NO

Return
true, when the underlying handle of this socket reference
and the parameter is identical.
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 direction of the bidirectional stream

Parameters
Direction

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.

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.
Return
Addr [out] receives the address.

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.
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
sal_Bool isRecvReady(
const TimeValue * pTimeout = 0 ) const;

virtual abstract const volatile template static inline C-linkage
NO NO YES NO NO NO YES NO

Description
Checks if read operations will block.
You can specify a timeout-value in seconds/nanoseconds that denotes
how sal_Int32 the operation will block if the Socket is not ready.
Return
True if read operations (recv, recvFrom, accept) on the Socket
will NOT block; 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
sal_Bool isSendReady(
const TimeValue * pTimeout = 0 ) const;

virtual abstract const volatile template static inline C-linkage
NO NO YES NO NO NO YES NO

Description
Checks if send operations will block.
You can specify a timeout-value in seconds/nanoseconds that denotes
how sal_Int32 the operation will block if the Socket is not ready.
Return
True if send operations (send, sendTo) on the Socket
will NOT block; 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
sal_Bool isExceptionPending(
const TimeValue * pTimeout = 0 ) const;

virtual abstract const volatile template static inline C-linkage
NO NO YES NO NO NO YES NO

Description
Checks if a request for out-of-band data will block.
You can specify a timeout-value in seconds/nanoseconds that denotes
how sal_Int32 the operation will block if the Socket has no pending OOB data.

Return
True if OOB-request operations (recv with appropriate flags) 
on the Socket will NOT block; 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:

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 = 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 immediatly.
  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 TLevel_Socket.

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 Level
- osl_Socket_LevelTcp    : Level of Transmission Control Protocol

Return
The size of the attribute copied into pBuffer ot -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 

If not above mentioned otherwise, the options are only valid for
level osl_Socket_LevelSocket.

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
for
a
complete
description
of
possible
options.

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
for
a
complete
description
of
possible
options.

enableNonBlockingMode
sal_Bool enableNonBlockingMode(
sal_Bool bNonBlockingMode );

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 True, blocking mode will be switched off
       If false, the socket will become a blocking
       socket (which is the default behaviour of a socket).
Return
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
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
Gets clears the error status
@returns the current error state.

getError
oslSocketError getError();

virtual abstract const volatile template static inline C-linkage
NO NO NO NO NO NO YES NO

Summary
Delivers a constant decribing the last error for the socket system.
Return
ENONE if no error occured, invalid_SocketError if
an unknown (unmapped) error occured, otherwise an enum describing the
error.

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

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.