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  * 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 {
30 
35  class SocketAddr
36  {
37  protected:
39  public:
40 
43  inline SocketAddr();
44 
47  inline SocketAddr(const SocketAddr& Addr);
48 
54  inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
55 
58  inline SocketAddr(oslSocketAddr Addr);
59 
65  inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
66 
69  inline ~SocketAddr();
70 
75  inline sal_Bool is() const;
76 
85  inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
86 
89  inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
90 
94  inline sal_Int32 SAL_CALL getPort() const;
95 
99  inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
100 
104  inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
105 
108  inline ::rtl::ByteSequence SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
109 
112  inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
113 
116  inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
117 
121  inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
122 
125  inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
126 
129  inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
130 
133  inline oslSocketAddr SAL_CALL getHandle() const;
134 
140  static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
141 
146  static inline void SAL_CALL resolveHostname(
147  const ::rtl::OUString & strHostName , SocketAddr & Addr );
148 
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:
165  protected:
171  inline Socket(oslSocketType Type,
174  public:
175  inline Socket( );
176 
177  inline Socket( const Socket & socket );
178 
179  inline Socket( oslSocket socketHandle );
180 
185  inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
186 
189  inline ~Socket();
190 
194  inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
195 
199  inline Socket& SAL_CALL operator= (const Socket& sock);
200 
205  inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
206 
211  inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
212 
218  inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
219 
225  inline void SAL_CALL close();
226 
231  inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
232 
236  inline sal_Int32 SAL_CALL getLocalPort() const;
237 
241  inline ::rtl::OUString SAL_CALL getLocalHost() const;
242 
246  inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
247 
251  inline sal_Int32 SAL_CALL getPeerPort() const;
252 
256  inline ::rtl::OUString SAL_CALL getPeerHost() const;
257 
262  inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
263 
274  inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
275 
286  inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
287 
288 
301  inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
302 
303 
315  inline oslSocketType SAL_CALL getType() const;
316 
398  inline sal_Int32 SAL_CALL getOption(
399  oslSocketOption Option,
400  void* pBuffer,
401  sal_uInt32 BufferLen,
403 
445  inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
446  void* pBuffer,
447  sal_uInt32 BufferLen,
449 
453  inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue );
454 
458  inline sal_Int32 getOption( oslSocketOption option ) const;
459 
466  inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
467 
471  inline sal_Bool SAL_CALL isNonBlockingMode() const;
472 
473 
476  inline void SAL_CALL clearError() const;
477 
485  inline oslSocketError getError() const;
486 
489  inline ::rtl::OUString getErrorAsString( ) const;
490 
493  inline oslSocket getHandle() const;
494  };
495 
496 
497  class StreamSocket : public Socket
498  {
499  public:
509 
510  inline StreamSocket( const StreamSocket & );
511 
512  inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
513 
514  inline StreamSocket( oslSocket Socket );
515 
525  inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
526 
534  inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
535 
536 
553  inline sal_Int32 SAL_CALL recv(void* pBuffer,
554  sal_uInt32 BytesToRead,
556 
573  sal_Int32 SAL_CALL send(const void* pBuffer,
574  sal_uInt32 BytesToSend,
576  };
577 
579  {
580  public:
590 
591 
601  oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
602  };
603 
606  class AcceptorSocket : public Socket
607  {
608  public:
612 
620  inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
621 
629  inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
630 
640  inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
641  };
642 
643 
644 
647  class DatagramSocket : public Socket
648  {
649  public:
650 
657 
677  inline sal_Int32 SAL_CALL recvFrom(void* pBuffer,
678  sal_uInt32 BufferSize,
679  SocketAddr* pSenderAddr= 0,
681 
704  inline sal_Int32 SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
705  const void* pBuffer,
706  sal_uInt32 BufferSize,
708  };
709 
710 }
711 
712 #endif
713 
714 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */