LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/osl - socket_decl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-12-17 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10