LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/osl - socket_decl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _OSL_SOCKET_DECL_HXX_
      30                 :            : #define _OSL_SOCKET_DECL_HXX_
      31                 :            : 
      32                 :            : #include <osl/socket.h>
      33                 :            : #include <rtl/ustring.hxx>
      34                 :            : #include <rtl/byteseq.hxx>
      35                 :            : 
      36                 :            : namespace osl
      37                 :            : {
      38                 :            :     enum __osl_socket_NoCopy { SAL_NO_COPY };
      39                 :            : 
      40                 :            :     /** The class should be understood as a reference to a socket address handle ( struct sockaddr ).
      41                 :            : 
      42                 :            :         The handle is mutable.
      43                 :            :      */
      44                 :            :     class SocketAddr
      45                 :            :     {
      46                 :            :     protected:
      47                 :            :         oslSocketAddr m_handle;
      48                 :            :     public:
      49                 :            : 
      50                 :            :         /** Creates socket address of unknown type.
      51                 :            :          */
      52                 :            :         inline SocketAddr();
      53                 :            : 
      54                 :            :         /** Copy constructor.
      55                 :            :          */
      56                 :            :         inline SocketAddr(const SocketAddr& Addr);
      57                 :            : 
      58                 :            :         /** The SocketAddr takes over the responsibility of the handle ( which means,
      59                 :            :             that the handle gets destructed by the destructor of this reference)
      60                 :            : 
      61                 :            :             @param nocopy use SAL_NO_COPY
      62                 :            :          */
      63                 :            :         inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
      64                 :            : 
      65                 :            :         /** Copyconstructs the oslSocketAddr handle.
      66                 :            :          */
      67                 :            :         inline SocketAddr(oslSocketAddr Addr);
      68                 :            : 
      69                 :            :         /** tcpip-specif constructor.
      70                 :            :             @param strAddrOrHostName strAddrOrHostName hostname or dotted ip-number of the network
      71                 :            :                                      interface, the socket shall be created on.
      72                 :            :             @param nPort             tcp-ip port number
      73                 :            :          */
      74                 :            :         inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
      75                 :            : 
      76                 :            :         /** destroys underlying oslSocketAddress
      77                 :            :          */
      78                 :            :         inline ~SocketAddr();
      79                 :            : 
      80                 :            :         /** checks, if the SocketAddr was created successful.
      81                 :            :             @return <code>sal_True</code> if there is a valid underlying handle,
      82                 :            :                     otherwise sal_False.
      83                 :            :          */
      84                 :            :         inline sal_Bool is() const;
      85                 :            : 
      86                 :            :         /** Converts the address to a (human readable) domain-name.
      87                 :            : 
      88                 :            :             @param pResult 0, if you are not interested in errors,
      89                 :            :                            otherwise *pResult contains an error code on failure
      90                 :            :                            or osl_Socket_Ok on success
      91                 :            :             @return the hostname of this SocketAddr or an empty string on failure.
      92                 :            :             @see osl_getHostnameOfSocketAddr()
      93                 :            :         */
      94                 :            :         inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
      95                 :            : 
      96                 :            :         /** Sets the ipaddress or hostname of the SocketAddress
      97                 :            :          */
      98                 :            :         inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
      99                 :            : 
     100                 :            :         /** Returns the port number of the address.
     101                 :            :             @return the port in host-byte order or or OSL_INVALID_PORT on errors.
     102                 :            :         */
     103                 :            :         inline sal_Int32 SAL_CALL getPort() const;
     104                 :            : 
     105                 :            :         /** Sets the port number of the address.
     106                 :            :            @return true if successfule.
     107                 :            :          */
     108                 :            :         inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
     109                 :            : 
     110                 :            :         /** Sets the address of the underlying socket address struct in network byte order.
     111                 :            :             @return true on success, false signales falure.
     112                 :            :          */
     113                 :            :         inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
     114                 :            : 
     115                 :            :         /** Returns the address of the underlying socket in network byte order
     116                 :            :           */
     117                 :            :         inline ::rtl::ByteSequence  SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
     118                 :            : 
     119                 :            :         /** assign the handle to this reference. The previous handle is released.
     120                 :            :         */
     121                 :            :         inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
     122                 :            : 
     123                 :            :         /**
     124                 :            :          */
     125                 :            :         inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
     126                 :            : 
     127                 :            :         /** Assigns the socket addr without copyconstructing it.
     128                 :            :             @param nocopy use SAL_NO_COPY
     129                 :            :           */
     130                 :            :         inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
     131                 :            : 
     132                 :            :         /** Returns true if the underlying handle is identical to the Addr handle.
     133                 :            :          */
     134                 :            :         inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
     135                 :            : 
     136                 :            :         /** Returns true if the underlying handle is identical to the Addr handle.
     137                 :            :          */
     138                 :            :         inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
     139                 :            : 
     140                 :            :         /** Returns the underlying SocketAddr handle without copyconstructing it.
     141                 :            :          */
     142                 :            :         inline oslSocketAddr SAL_CALL getHandle() const;
     143                 :            : 
     144                 :            :         /** Get the hostname for the local interface.
     145                 :            :             @param pResult after the call *pResult contains osl_Socket_Ok on success or
     146                 :            :                    an error on failure.
     147                 :            :             @return the hostname
     148                 :            :         */
     149                 :            :         static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
     150                 :            : 
     151                 :            :         /** Tries to find an address for a host.
     152                 :            :             @see osl_resolveHostname()
     153                 :            :             @return A new created socket-address or 0 if the name could not be found.
     154                 :            :         */
     155                 :            :         static inline void SAL_CALL resolveHostname(
     156                 :            :             const ::rtl::OUString & strHostName , SocketAddr & Addr );
     157                 :            : 
     158                 :            :         /**
     159                 :            :            Tries to find the port associated with the given service/protocol-
     160                 :            :            pair (e.g. "ftp"/"tcp").
     161                 :            :            @return the port number in host-byte order or <code>OSL_INVALID_PORT</code>
     162                 :            :            if no service/protocol pair could be found.
     163                 :            :         */
     164                 :            :         static inline sal_Int32 SAL_CALL getServicePort(
     165                 :            :             const ::rtl::OUString& strServiceName,
     166                 :            :             const ::rtl::OUString & strProtocolName= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("tcp")) );
     167                 :            :     };
     168                 :            : 
     169                 :            : 
     170                 :            :     class Socket
     171                 :            :     {
     172                 :            :     protected:
     173                 :            :         oslSocket m_handle;
     174                 :            :     protected:
     175                 :            :         /** Creates a socket. Note it's protected.
     176                 :            :             @param Type
     177                 :            :             @param Family
     178                 :            :             @param Protocol
     179                 :            :         */
     180                 :            :         inline Socket(oslSocketType Type,
     181                 :            :                       oslAddrFamily Family = osl_Socket_FamilyInet,
     182                 :            :                       oslProtocol   Protocol = osl_Socket_ProtocolIp);
     183                 :            :     public:
     184                 :            :         inline Socket( );
     185                 :            : 
     186                 :            :         inline Socket( const Socket & socket );
     187                 :            : 
     188                 :            :         inline Socket( oslSocket socketHandle );
     189                 :            : 
     190                 :            :         /** The instance takes over the handle's ownership without acquiring the
     191                 :            :             handle, but releases it within the dtor.
     192                 :            :             @param noacquire use SAL_NO_ACQUIRE
     193                 :            :          */
     194                 :            :         inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
     195                 :            : 
     196                 :            :         /** Destructor. Releases the underlying handle
     197                 :            :          */
     198                 :            :         inline ~Socket();
     199                 :            : 
     200                 :            :         /** Assignment operator. If socket was already created, the old one will
     201                 :            :             be discarded.
     202                 :            :         */
     203                 :            :         inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
     204                 :            : 
     205                 :            :         /** Assignment operator. If socket was already created, the old one will
     206                 :            :             be discarded.
     207                 :            :         */
     208                 :            :         inline Socket& SAL_CALL operator= (const Socket& sock);
     209                 :            : 
     210                 :            :         /**
     211                 :            :            @return <code>sal_True</code>, when the underlying handle of both
     212                 :            :                          Socket instances are identical, <code>sal_False</code> otherwise.
     213                 :            :          */
     214                 :            :         inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
     215                 :            : 
     216                 :            :         /**
     217                 :            :            @return <code>sal_True</code>, when the underlying handle of both
     218                 :            :                          Socket instances are identical, <code>sal_False</code> otherwise.
     219                 :            :          */
     220                 :            :         inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
     221                 :            : 
     222                 :            :         /** Closes a definite or both directions of the bidirectional stream.
     223                 :            : 
     224                 :            :            @param Direction
     225                 :            :            @see osl_shutdownSocket()
     226                 :            :          */
     227                 :            :         inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
     228                 :            : 
     229                 :            :         /** Closes a socket.
     230                 :            :             Note that closing a socket is identical to shutdown( osl_Socket_DirReadWrite ),
     231                 :            :             as the operating system distinguish both cases, both functions or offered in this API.
     232                 :            :             @see osl_closeSocket()
     233                 :            :          */
     234                 :            :         inline void SAL_CALL close();
     235                 :            : 
     236                 :            :         /** Retrieves the address of the local interface of this socket.
     237                 :            :             @param Addr [out] receives the address.
     238                 :            :             @see osl_getLocalAddrOfSocket()
     239                 :            :         */
     240                 :            :         inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
     241                 :            : 
     242                 :            :         /** Get the local port of the socket. Usually used after bind().
     243                 :            :             @return the port number or OSL_INVALID_PORT on errors.
     244                 :            :         */
     245                 :            :         inline sal_Int32    SAL_CALL getLocalPort() const;
     246                 :            : 
     247                 :            :         /** Get the hostname for the local interface.
     248                 :            :             @return the hostname or an empty string ("").
     249                 :            :         */
     250                 :            :         inline ::rtl::OUString SAL_CALL getLocalHost() const;
     251                 :            : 
     252                 :            :         /** Retrieves the address of the remote host of this socket.
     253                 :            :             @param Addr [out] receives the address.
     254                 :            :         */
     255                 :            :         inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
     256                 :            : 
     257                 :            :         /** Get the remote port of the socket.
     258                 :            :             @return the port number or OSL_INVALID_PORT on errors.
     259                 :            :         */
     260                 :            :         inline sal_Int32    SAL_CALL getPeerPort() const;
     261                 :            : 
     262                 :            :         /** Get the hostname for the remote interface.
     263                 :            :             @return the hostname or an empty string ("").
     264                 :            :         */
     265                 :            :         inline ::rtl::OUString SAL_CALL getPeerHost() const;
     266                 :            : 
     267                 :            :         /** Binds the socket to the specified (local) interface.
     268                 :            :             @param LocalInterface Address of the Interface
     269                 :            :             @return True if bind was successful.
     270                 :            :         */
     271                 :            :         inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
     272                 :            : 
     273                 :            :         /** Checks if read operations will block.
     274                 :            : 
     275                 :            :             You can specify a timeout-value in seconds/nanoseconds that denotes
     276                 :            :             how the operation will block if the Socket is not ready.
     277                 :            :             @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
     278                 :            :             will NOT block; <code>sal_False</code> if it would block or if an error occurred.
     279                 :            : 
     280                 :            :             @param pTimeout if 0, the operation will block without a timeout. Otherwise
     281                 :            :             the specified amout of time.
     282                 :            :         */
     283                 :            :         inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
     284                 :            : 
     285                 :            :         /** Checks if send operations will block.
     286                 :            : 
     287                 :            :             You can specify a timeout-value in seconds/nanoseconds that denotes
     288                 :            :             how the operation will block if the Socket is not ready.
     289                 :            :             @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
     290                 :            :             will NOT block; <code>sal_False</code> if it would block or if an error occurred.
     291                 :            : 
     292                 :            :             @param pTimeout if 0, the operation will block without a timeout. Otherwise
     293                 :            :             the specified amout of time.
     294                 :            :         */
     295                 :            :         inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
     296                 :            : 
     297                 :            : 
     298                 :            :         /** Checks if a request for out-of-band data will block.
     299                 :            : 
     300                 :            :             You can specify a timeout-value in seconds/nanoseconds that denotes
     301                 :            :             how the operation will block if the Socket has no pending OOB data.
     302                 :            : 
     303                 :            :             @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
     304                 :            :             on the Socket will NOT block; <code>sal_False</code> if it would block or if
     305                 :            :             an error occurred.
     306                 :            : 
     307                 :            :             @param pTimeout if 0, the operation will block without a timeout. Otherwise
     308                 :            :             the specified amout of time.
     309                 :            :         */
     310                 :            :         inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
     311                 :            : 
     312                 :            : 
     313                 :            :         /** Queries the socket for its type.
     314                 :            :             @return one of:
     315                 :            :             <ul>
     316                 :            :             <li> <code>osl_Socket_TypeStream</code>
     317                 :            :             <li> <code>osl_Socket_TypeDgram</code>
     318                 :            :             <li> <code>osl_Socket_TypeRaw</code>
     319                 :            :             <li> <code>osl_Socket_TypeRdm</code>
     320                 :            :             <li> <code>osl_Socket_TypeSeqPacket</code>
     321                 :            :             <li> <code>osl_invalid_SocketType</code>, if an error occurred
     322                 :            :             </ul>
     323                 :            :         */
     324                 :            :         inline oslSocketType    SAL_CALL getType() const;
     325                 :            : 
     326                 :            :         /** Retrieves option-attributes associated with the socket.
     327                 :            :             @param Option The attribute to query.
     328                 :            :             Valid values (depending on the Level) are:
     329                 :            :             <ul>
     330                 :            :             <li> <code>osl_Socket_Option_Debug</code><br>
     331                 :            :                  (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
     332                 :            : 
     333                 :            :             <li> <code>osl_Socket_OptionAcceptConn</code><br>
     334                 :            :             <li> <code>osl_Socket_OptionReuseAddr</code><br>
     335                 :            :               (sal_Bool) Allows the socket to be bound to an address that is
     336                 :            :               already in use.
     337                 :            :               1 = multiple bound allowed, 0 = no multiple bounds allowed
     338                 :            : 
     339                 :            :             <li><code>osl_Socket_OptionKeepAlive</code><br>
     340                 :            :                (sal_Bool) Keepalive packets are sent by the underlying socket.
     341                 :            :                1 = enabled, 0 = disabled
     342                 :            : 
     343                 :            :             <li><code>osl_Socket_OptionDontRoute</code><br>
     344                 :            :                (sal_Bool) Do not route: send directly to interface.
     345                 :            :                   1 = do not route , 0 = routing possible
     346                 :            : 
     347                 :            :             <li><code>osl_Socket_OptionBroadcast</code><br>
     348                 :            :                (sal_Bool) Transmission of broadcast messages are allowed on the socket.
     349                 :            :                1 = transmission allowed, 0 = transmission disallowed
     350                 :            : 
     351                 :            :             <li><code>osl_Socket_OptionUseLoopback</code><br>
     352                 :            : 
     353                 :            :             <li><code>osl_Socket_OptionLinger</code><br>
     354                 :            :                (linger) Linger on close if unsent data is present.
     355                 :            :                linger has two members: l_onoff, l_linger
     356                 :            :                l_onoff = 0 is off, l_onoff > 0 and l_linger= timeout in seconds.
     357                 :            : 
     358                 :            :             <li><code>osl_Socket_OptionOOBinLine</code><br>
     359                 :            : 
     360                 :            : 
     361                 :            :             <li><code>osl_Socket_OptionSndBuf</code><br>
     362                 :            :               (sal_Int32) Size of the send buffer in bytes. Data is sent after
     363                 :            :               SndTimeo or when the buffer is full. This allows faster writing
     364                 :            :               to the socket.
     365                 :            : 
     366                 :            :             <li><code>osl_Socket_OptionRcvBuf</code><br>
     367                 :            :               (sal_Int32) Size of the receive buffer in bytes. Data is sent after
     368                 :            :               SndTimeo or when the buffer is full. This allows faster writing
     369                 :            :               to the socket and larger packet sizes.
     370                 :            : 
     371                 :            :             <li><code>osl_Socket_OptionSndLowat</code><br>
     372                 :            : 
     373                 :            :             <li><code>osl_Socket_OptionRcvLowat</code><br>
     374                 :            : 
     375                 :            :             <li><code>osl_Socket_OptionSndTimeo</code><br>
     376                 :            :               (sal_Int32) Data is sent after this timeout. This allows gathering
     377                 :            :               of data to send larger packages but increases latency times.
     378                 :            : 
     379                 :            :             <li><code>osl_Socket_OptionRcvTimeo</code><br>
     380                 :            : 
     381                 :            :             <li><code>osl_Socket_OptionError</code><br>
     382                 :            :             <li><code>osl_Socket_OptionType</code><br>
     383                 :            : 
     384                 :            :             <li><code>osl_Socket_OptionTcpNoDelay</code><br>
     385                 :            :               Disables the Nagle algorithm for send coalescing. (Do not
     386                 :            :               collect data until a packet is full, instead send immediatly.
     387                 :            :               This increases network traffic but might improve latency-times.)
     388                 :            :               1 = disables the algorithm, 0 = keeps it enabled.
     389                 :            :             </ul>
     390                 :            : 
     391                 :            :               If not above mentioned otherwise, the options are only valid for
     392                 :            :               level <code>osl_Socket_LevelSocket</code>.
     393                 :            :             @param pBuffer The Buffer will be filled with the attribute.
     394                 :            : 
     395                 :            :             @param BufferLen The size of pBuffer.
     396                 :            : 
     397                 :            :             @param Level The option level.
     398                 :            : 
     399                 :            :             Valid values are:
     400                 :            :             <ul>
     401                 :            :             <li><code>osl_Socket_LevelSocket</code> : Socket Level
     402                 :            :             <li><code>osl_Socket_LevelTcp</code>    : Level of Transmission Control Protocol
     403                 :            :             </ul>
     404                 :            :             @return The size of the attribute copied into pBuffer or -1 if an error
     405                 :            :             occurred.
     406                 :            :         */
     407                 :            :         inline sal_Int32 SAL_CALL getOption(
     408                 :            :             oslSocketOption Option,
     409                 :            :             void* pBuffer,
     410                 :            :             sal_uInt32 BufferLen,
     411                 :            :             oslSocketOptionLevel Level= osl_Socket_LevelSocket) const;
     412                 :            : 
     413                 :            :         /** Sets the sockets attributes.
     414                 :            : 
     415                 :            :             @param Option denotes the option to modify.
     416                 :            :             Valid values (depending on the Level) are:
     417                 :            :             <ul>
     418                 :            :             <li> osl_Socket_Option_Debug
     419                 :            :             <li> osl_Socket_OptionAcceptConn
     420                 :            :             <li> osl_Socket_OptionReuseAddr
     421                 :            :             <li> osl_Socket_OptionKeepAlive
     422                 :            :             <li> osl_Socket_OptionDontRoute
     423                 :            :             <li> osl_Socket_OptionBroadcast
     424                 :            :             <li> osl_Socket_OptionUseLoopback
     425                 :            :             <li> osl_Socket_OptionLinger
     426                 :            :             <li> osl_Socket_OptionOOBinLine
     427                 :            :             <li> osl_Socket_OptionSndBuf
     428                 :            :             <li> osl_Socket_OptionRcvBuf
     429                 :            :             <li> osl_Socket_OptionSndLowat
     430                 :            :             <li> osl_Socket_OptionRcvLowat
     431                 :            :             <li> osl_Socket_OptionSndTimeo
     432                 :            :             <li> osl_Socket_OptionRcvTimeo
     433                 :            :             <li> osl_Socket_OptionError
     434                 :            :             <li> osl_Socket_OptionType
     435                 :            :             <li> osl_Socket_OptionTcpNoDelay
     436                 :            :             </ul>
     437                 :            : 
     438                 :            :             If not above mentioned otherwise, the options are only valid for
     439                 :            :             level osl_Socket_LevelSocket.
     440                 :            : 
     441                 :            :             @param pBuffer Pointer to a Buffer which contains the attribute-value.
     442                 :            : 
     443                 :            :             @param BufferLen contains the length of the Buffer.
     444                 :            : 
     445                 :            :             @param Level selects the level for which an option should be changed.
     446                 :            :             Valid values are:
     447                 :            :             <ul>
     448                 :            :             <li> osl_Socket_evel_Socket : Socket Level
     449                 :            :             <li> osl_Socket_Level_Tcp   : Level of Transmission Control Protocol
     450                 :            :             </ul>
     451                 :            : 
     452                 :            :             @return True if the option could be changed.
     453                 :            :         */
     454                 :            :         inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
     455                 :            :                                             void* pBuffer,
     456                 :            :                                             sal_uInt32 BufferLen,
     457                 :            :                                             oslSocketOptionLevel Level= osl_Socket_LevelSocket ) const;
     458                 :            : 
     459                 :            :         /** Convenience function for setting sal_Bool and sal_Int32 option values.
     460                 :            :             @see setOption()
     461                 :            :          */
     462                 :            :         inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue  );
     463                 :            : 
     464                 :            :         /** Convenience function for retrieving sal_Bool and sal_Int32 option values.
     465                 :            :             @see setOption()
     466                 :            :          */
     467                 :            :         inline sal_Int32 getOption( oslSocketOption option ) const;
     468                 :            : 
     469                 :            :         /** Enables/disables non-blocking mode of the socket.
     470                 :            :             @param bNonBlockingMode If <code>sal_True</code>, blocking mode will be switched off
     471                 :            :                    If <code>sal_False</code>, the socket will become a blocking
     472                 :            :                    socket (which is the default behaviour of a socket).
     473                 :            :             @return <code>sal_True</code> if mode could be set.
     474                 :            :         */
     475                 :            :         inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
     476                 :            : 
     477                 :            :         /** Query blocking mode of the socket.
     478                 :            :             @return <code>sal_True</code> if non-blocking mode is set.
     479                 :            :         */
     480                 :            :         inline sal_Bool SAL_CALL isNonBlockingMode() const;
     481                 :            : 
     482                 :            : 
     483                 :            :         /** clears the error status
     484                 :            :         */
     485                 :            :         inline void SAL_CALL clearError() const;
     486                 :            : 
     487                 :            :         /** returns a constant decribing the last error for the socket system.
     488                 :            : 
     489                 :            :             @return osl_Socket_E_NONE if no error occurred, invalid_SocketError if
     490                 :            :             an unknown (unmapped) error occurred, otherwise an enum describing the
     491                 :            :             error.
     492                 :            :             @see osl_getLastSocketError()
     493                 :            :         */
     494                 :            :         inline oslSocketError getError() const;
     495                 :            : 
     496                 :            :         /** Builds a string with the last error-message for the socket.
     497                 :            :          */
     498                 :            :         inline ::rtl::OUString getErrorAsString( ) const;
     499                 :            : 
     500                 :            :         /** Returns the underlying handle unacquired  (The caller must acquire it to keep it).
     501                 :            :          */
     502                 :            :         inline oslSocket getHandle() const;
     503                 :            :     };
     504                 :            : 
     505                 :            : 
     506                 :          0 :     class StreamSocket : public Socket
     507                 :            :     {
     508                 :            :     public:
     509                 :            :         /** Creates a socket.
     510                 :            :             @param Type For some protocols it might be desirable to
     511                 :            :             use a different type than <code>osl_Socket_TypeStream</code>
     512                 :            :             (like <code>osl_Socket_TypeSeqPacket</code>).
     513                 :            :             Therefore this parameter is not hidden.
     514                 :            :         */
     515                 :            :           inline StreamSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
     516                 :            :                             oslProtocol Protocol = osl_Socket_ProtocolIp,
     517                 :            :                             oslSocketType   Type = osl_Socket_TypeStream);
     518                 :            : 
     519                 :            :         inline StreamSocket( const StreamSocket & );
     520                 :            : 
     521                 :            :         inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
     522                 :            : 
     523                 :            :         inline StreamSocket( oslSocket Socket );
     524                 :            : 
     525                 :            :         /** Retrieves n bytes from the stream and copies them into pBuffer.
     526                 :            :             The method avoids incomplete reads due to packet boundaries and is thus
     527                 :            :             blocking.
     528                 :            :             @param pBuffer receives the read data. pBuffer must be large enough
     529                 :            :             to hold n bytes.
     530                 :            :             @param n the number of bytes to read.
     531                 :            :             @return the number of read bytes. The number will only be smaller than
     532                 :            :             n if an exceptional condition (e.g. connection closed) occurs.
     533                 :            :         */
     534                 :            :         inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
     535                 :            : 
     536                 :            :         /** Writes n bytes from pBuffer to the stream. The method avoids
     537                 :            :             incomplete writes due to packet boundaries and is thus blocking.
     538                 :            :             @param pBuffer contains the data to be written.
     539                 :            :             @param n the number of bytes to write.
     540                 :            :             @return the number of written bytes. The number will only be smaller than
     541                 :            :             n if an exceptional condition (e.g. connection closed) occurs.
     542                 :            :         */
     543                 :            :         inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
     544                 :            : 
     545                 :            : 
     546                 :            :         /** Tries to receive BytesToRead data from the connected socket,
     547                 :            : 
     548                 :            :             @param[out] pBuffer Points to a buffer that will be filled with the received
     549                 :            :             data. pBuffer must have at least have a size of BytesToRead.
     550                 :            :             @param[in] BytesToRead The number of bytes to read.
     551                 :            :             @param[in] flags Modifier for the call. Valid values are:
     552                 :            : 
     553                 :            :             <ul>
     554                 :            :             <li><code>osl_Socket_MsgNormal</code>
     555                 :            :             <li><code>osl_Socket_MsgOOB</code>
     556                 :            :             <li><code>osl_Socket_MsgPeek</code>
     557                 :            :             <li><code>osl_Socket_MsgDontRoute</code>
     558                 :            :             <li><code>osl_Socket_MsgMaxIOVLen</code>
     559                 :            :             </ul>
     560                 :            :             @return the number of received bytes, which may be less than BytesToRead.
     561                 :            :         */
     562                 :            :         inline sal_Int32 SAL_CALL recv(void* pBuffer,
     563                 :            :                                        sal_uInt32 BytesToRead,
     564                 :            :                                        oslSocketMsgFlag flags= osl_Socket_MsgNormal);
     565                 :            : 
     566                 :            :         /** Tries to send BytesToSend data to the connected socket.
     567                 :            : 
     568                 :            :             @param pBuffer [in] Points to a buffer that contains the send-data.
     569                 :            :             @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
     570                 :            :             this size.
     571                 :            :             @param Flag [in] Modifier for the call. Valid values are:
     572                 :            :             <ul>
     573                 :            :             <li><code>osl_Socket_MsgNormal</code>
     574                 :            :             <li><code>osl_Socket_MsgOOB</code>
     575                 :            :             <li><code>osl_Socket_MsgPeek</code>
     576                 :            :             <li><code>osl_Socket_MsgDontRoute</code>
     577                 :            :             <li><code>osl_Socket_MsgMaxIOVLen</code>
     578                 :            :             </ul>
     579                 :            : 
     580                 :            :             @return the number of transfered bytes. It may be less than BytesToSend.
     581                 :            :         */
     582                 :            :         sal_Int32 SAL_CALL send(const void* pBuffer,
     583                 :            :                                 sal_uInt32 BytesToSend,
     584                 :            :                                 oslSocketMsgFlag= osl_Socket_MsgNormal);
     585                 :            :     };
     586                 :            : 
     587                 :          0 :     class ConnectorSocket : public StreamSocket
     588                 :            :     {
     589                 :            :     public:
     590                 :            :         /** Creates a socket that can connect to a (remote) host.
     591                 :            :             @param Type For some protocols it might be desirable to
     592                 :            :             use a different type than sock_stream <code>osl_Socket_TypeSeqPacket</code>
     593                 :            :             (like <code>osl_Socket_TypeSeqPacket</code>).
     594                 :            :             Therefore we do not hide this parameter here.
     595                 :            :         */
     596                 :            :           ConnectorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
     597                 :            :                         oslProtocol Protocol = osl_Socket_ProtocolIp,
     598                 :            :                         oslSocketType   Type = osl_Socket_TypeStream);
     599                 :            : 
     600                 :            : 
     601                 :            :         /** Connects the socket to a (remote) host.
     602                 :            :             @param TargetHost The address of the target.
     603                 :            :             @param pTimeout The timeout for blocking. If 0, a default system dependent timeout
     604                 :            :                             us used.
     605                 :            :             @return <code> osl_Socket_Ok</code> if connected successfully,
     606                 :            :             <code>osl_Socket_TimedOut</code> on timeout,
     607                 :            :             <code>osl_Socket_Interrupted</code> if unblocked forcefully (by osl::Socket::close()),
     608                 :            :             <code>osl_Socket_Error</code> if connect failed.
     609                 :            :         */
     610                 :            :         oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
     611                 :            :     };
     612                 :            : 
     613                 :            :     /** Allows to accept socket connections.
     614                 :            :      */
     615                 :          0 :     class AcceptorSocket : public Socket
     616                 :            :     {
     617                 :            :     public:
     618                 :            :         inline AcceptorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
     619                 :            :                               oslProtocol   Protocol = osl_Socket_ProtocolIp,
     620                 :            :                               oslSocketType Type = osl_Socket_TypeStream);
     621                 :            : 
     622                 :            :         /** Prepare a socket for the accept-call. The socket must have been
     623                 :            :             bound before to the local address.
     624                 :            :             @param MaxPendingConnections The maximum number of pending
     625                 :            :             connections (waiting to be accepted) on this socket. If you use
     626                 :            :             -1, a system default value is used.
     627                 :            :             @return <code>sal_True</code> if call was successful.
     628                 :            :         */
     629                 :            :         inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
     630                 :            : 
     631                 :            :         /** Accepts incoming connections on the socket. You must
     632                 :            :             precede this call with osl::Socket::bind() and listen().
     633                 :            :             @param Connection receives the incoming connection.
     634                 :            :             @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
     635                 :            :             <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
     636                 :            :             <code>osl_Socket_Error</code> on errors.
     637                 :            :         */
     638                 :            :         inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
     639                 :            : 
     640                 :            :         /** Accepts incoming connections on the socket. You must
     641                 :            :             precede this call with osl::Socket::bind() and listen().
     642                 :            :             @param PeerAddr receives the address of the connecting entity
     643                 :            :             (your communication partner).
     644                 :            :             @param Connection receives the incoming connection.
     645                 :            :             @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
     646                 :            :             <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
     647                 :            :             <code>osl_Socket_Error</code> on errors.
     648                 :            :         */
     649                 :            :         inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
     650                 :            :     };
     651                 :            : 
     652                 :            : 
     653                 :            : 
     654                 :            :     /** A connectionless socket to send and receive datagrams.
     655                 :            :      */
     656                 :            :     class DatagramSocket : public Socket
     657                 :            :     {
     658                 :            :     public:
     659                 :            : 
     660                 :            :         /** Creates a datagram socket.
     661                 :            :             @param Type is sock_dgram by default.
     662                 :            :         */
     663                 :            :         inline DatagramSocket(oslAddrFamily Family= osl_Socket_FamilyInet,
     664                 :            :                               oslProtocol   Protocol= osl_Socket_ProtocolIp,
     665                 :            :                               oslSocketType Type= osl_Socket_TypeDgram);
     666                 :            : 
     667                 :            :         /** Tries to receives BufferSize data from the socket, if no error occurs.
     668                 :            : 
     669                 :            :             @param pSenderAddr [out] You must provide pointer to a SocketAddr.
     670                 :            :             It will be  filled with the address of the datagrams sender.
     671                 :            :             If pSenderAddr is 0, it is ignored.
     672                 :            :             @param pBuffer [out] Points to a buffer that will be filled with the received
     673                 :            :             datagram.
     674                 :            :             @param BufferSize [in] The size of pBuffer.
     675                 :            :             @param Flag [in] Modifier for the call. Valid values are:
     676                 :            :             <ul>
     677                 :            :             <li><code>osl_Socket_MsgNormal</code>
     678                 :            :             <li><code>osl_Socket_MsgOOB</code>
     679                 :            :             <li><code>osl_Socket_MsgPeek</code>
     680                 :            :             <li><code>osl_Socket_MsgDontRoute</code>
     681                 :            :             <li><code>osl_Socket_MsgMaxIOVLen</code>
     682                 :            :             </ul>
     683                 :            : 
     684                 :            :             @return the number of received bytes.
     685                 :            :         */
     686                 :            :         inline sal_Int32 SAL_CALL recvFrom(void*  pBuffer,
     687                 :            :                                            sal_uInt32 BufferSize,
     688                 :            :                                            SocketAddr* pSenderAddr= 0,
     689                 :            :                                            oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
     690                 :            : 
     691                 :            :         /** Tries to send one datagram with BytesToSend size to the given ReceiverAddr.
     692                 :            :             Since there is only send one packet, the function doesn't care about
     693                 :            :             packet boundaries.
     694                 :            : 
     695                 :            :             @param ReceiverAddr [in] A SocketAddr that contains
     696                 :            :             the destination address for this send.
     697                 :            : 
     698                 :            :             @param pBuffer [in] Points to a buffer that contains the send-data.
     699                 :            :             @param BufferSize [in] The number of bytes to send. pBuffer must have at least
     700                 :            :             this size.
     701                 :            :             @param Flag [in] Modifier for the call. Valid values are:
     702                 :            : 
     703                 :            :             <ul>
     704                 :            :             <li><code>osl_Socket_MsgNormal</code>
     705                 :            :             <li><code>osl_Socket_MsgOOB</code>
     706                 :            :             <li><code>osl_Socket_MsgPeek</code>
     707                 :            :             <li><code>osl_Socket_MsgDontRoute</code>
     708                 :            :             <li><code>osl_Socket_MsgMaxIOVLen</code>
     709                 :            :             </ul>
     710                 :            : 
     711                 :            :             @return the number of transfered bytes.
     712                 :            :         */
     713                 :            :         inline sal_Int32    SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
     714                 :            :                                              const void* pBuffer,
     715                 :            :                                              sal_uInt32 BufferSize,
     716                 :            :                                              oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
     717                 :            :     };
     718                 :            : 
     719                 :            : }
     720                 :            : 
     721                 :            : #endif
     722                 :            : 
     723                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10