My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
socket_decl.hxx
Go to the documentation of this file.
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 {
39 
44  class SocketAddr
45  {
46  protected:
48  public:
49 
52  inline SocketAddr();
53 
56  inline SocketAddr(const SocketAddr& Addr);
57 
63  inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
64 
67  inline SocketAddr(oslSocketAddr Addr);
68 
74  inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
75 
78  inline ~SocketAddr();
79 
84  inline sal_Bool is() const;
85 
94  inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
95 
98  inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
99 
103  inline sal_Int32 SAL_CALL getPort() const;
104 
108  inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
109 
113  inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
114 
117  inline ::rtl::ByteSequence SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
118 
121  inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
122 
125  inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
126 
130  inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
131 
134  inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
135 
138  inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
139 
142  inline oslSocketAddr SAL_CALL getHandle() const;
143 
149  static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
150 
155  static inline void SAL_CALL resolveHostname(
156  const ::rtl::OUString & strHostName , SocketAddr & Addr );
157 
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:
174  protected:
180  inline Socket(oslSocketType Type,
183  public:
184  inline Socket( );
185 
186  inline Socket( const Socket & socket );
187 
188  inline Socket( oslSocket socketHandle );
189 
194  inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
195 
198  inline ~Socket();
199 
203  inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
204 
208  inline Socket& SAL_CALL operator= (const Socket& sock);
209 
214  inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
215 
220  inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
221 
227  inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
228 
234  inline void SAL_CALL close();
235 
240  inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
241 
245  inline sal_Int32 SAL_CALL getLocalPort() const;
246 
250  inline ::rtl::OUString SAL_CALL getLocalHost() const;
251 
255  inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
256 
260  inline sal_Int32 SAL_CALL getPeerPort() const;
261 
265  inline ::rtl::OUString SAL_CALL getPeerHost() const;
266 
271  inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
272 
283  inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
284 
295  inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
296 
297 
310  inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
311 
312 
324  inline oslSocketType SAL_CALL getType() const;
325 
407  inline sal_Int32 SAL_CALL getOption(
408  oslSocketOption Option,
409  void* pBuffer,
410  sal_uInt32 BufferLen,
412 
454  inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
455  void* pBuffer,
456  sal_uInt32 BufferLen,
458 
462  inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue );
463 
467  inline sal_Int32 getOption( oslSocketOption option ) const;
468 
475  inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
476 
480  inline sal_Bool SAL_CALL isNonBlockingMode() const;
481 
482 
485  inline void SAL_CALL clearError() const;
486 
494  inline oslSocketError getError() const;
495 
498  inline ::rtl::OUString getErrorAsString( ) const;
499 
502  inline oslSocket getHandle() const;
503  };
504 
505 
506  class StreamSocket : public Socket
507  {
508  public:
518 
519  inline StreamSocket( const StreamSocket & );
520 
521  inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
522 
523  inline StreamSocket( oslSocket Socket );
524 
534  inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
535 
543  inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
544 
545 
562  inline sal_Int32 SAL_CALL recv(void* pBuffer,
563  sal_uInt32 BytesToRead,
565 
582  sal_Int32 SAL_CALL send(const void* pBuffer,
583  sal_uInt32 BytesToSend,
585  };
586 
588  {
589  public:
599 
600 
610  oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
611  };
612 
615  class AcceptorSocket : public Socket
616  {
617  public:
621 
629  inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
630 
638  inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
639 
649  inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
650  };
651 
652 
653 
656  class DatagramSocket : public Socket
657  {
658  public:
659 
666 
686  inline sal_Int32 SAL_CALL recvFrom(void* pBuffer,
687  sal_uInt32 BufferSize,
688  SocketAddr* pSenderAddr= 0,
690 
713  inline sal_Int32 SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
714  const void* pBuffer,
715  sal_uInt32 BufferSize,
717  };
718 
719 }
720 
721 #endif
722 
723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */