AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
socket.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 #ifndef INCLUDED_OSL_SOCKET_HXX
5 #define INCLUDED_OSL_SOCKET_HXX
6 
7 #include "osl/socket_decl.hxx"
8 
9 namespace osl
10 {
11 
14  {}
15 
16 
17  inline SocketAddr::SocketAddr(const SocketAddr& Addr)
18  : m_handle( osl_copySocketAddr( Addr.m_handle ) )
19  {
20  }
21 
22 #if defined LIBO_INTERNAL_ONLY
23  SocketAddr::SocketAddr(SocketAddr && other) noexcept : m_handle(other.m_handle) {
24  other.m_handle = nullptr;
25  }
26 #endif
27 
29  : m_handle( osl_copySocketAddr( Addr ) )
30  {
31  }
32 
33 
35  : m_handle( Addr )
36  {
37  }
38 
39 
40  inline SocketAddr::SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort)
41  : m_handle( osl_createInetSocketAddr( strAddrOrHostName.pData, nPort ) )
42  {
43  if(! m_handle )
44  {
45  m_handle = osl_resolveHostname(strAddrOrHostName.pData);
46 
47  // host found?
48  if(m_handle)
49  {
51  }
52  else
53  {
55  m_handle = NULL;
56  }
57  }
58  }
59 
60 
62  {
63  if( m_handle )
65  }
66 
67 
68  inline ::rtl::OUString SocketAddr::getHostname( oslSocketResult *pResult ) const
69  {
70  ::rtl::OUString hostname;
72  if( pResult )
73  *pResult = result;
74  return hostname;
75  }
76 
77 
78  inline sal_Int32 SAL_CALL SocketAddr::getPort() const
79  {
81  }
82 
83 
84  inline bool SAL_CALL SocketAddr::setPort( sal_Int32 nPort )
85  {
86  return osl_setInetPortOfSocketAddr(m_handle, nPort );
87  }
88 
89  inline bool SAL_CALL SocketAddr::setHostname( const ::rtl::OUString &sDottedIpOrHostname )
90  {
91  *this = SocketAddr( sDottedIpOrHostname , getPort() );
92  return is();
93  }
94 
95 
96  inline bool SAL_CALL SocketAddr::setAddr( const ::rtl::ByteSequence & address )
97  {
98  return osl_setAddrOfSocketAddr( m_handle, address.getHandle() )
99  == osl_Socket_Ok;
100  }
101 
102  inline ::rtl::ByteSequence SAL_CALL SocketAddr::getAddr( oslSocketResult *pResult ) const
103  {
104  ::rtl::ByteSequence sequence;
105  oslSocketResult result = osl_getAddrOfSocketAddr( m_handle, reinterpret_cast<sal_Sequence **>(&sequence) );
106  if( pResult )
107  *pResult = result;
108  return sequence;
109  }
110 
111 
113  {
114  oslSocketAddr pNewAddr = osl_copySocketAddr( Addr );
115  if( m_handle )
117  m_handle = pNewAddr;
118  return *this;
119  }
120 
121 
122  inline SocketAddr & SAL_CALL SocketAddr::operator= (const SocketAddr& Addr)
123  {
124  *this = Addr.getHandle();
125  return *this;
126  }
127 
128 #if defined LIBO_INTERNAL_ONLY
129  SocketAddr & SocketAddr::operator =(SocketAddr && other) noexcept {
130  if (m_handle != nullptr) {
132  }
133  m_handle = other.m_handle;
134  other.m_handle = nullptr;
135  return *this;
136  }
137 #endif
138 
140  {
141  if( m_handle )
143  m_handle = Addr;
144  return *this;
145  }
146 
147 
148  inline bool SAL_CALL SocketAddr::operator== (oslSocketAddr Addr) const
149  {
150  return osl_isEqualSocketAddr( m_handle, Addr );
151  }
152 
154  {
155  return m_handle;
156  }
157 
158 
159  inline bool SocketAddr::is() const
160  {
161  return m_handle != NULL;
162  }
163 
164  inline ::rtl::OUString SAL_CALL SocketAddr::getLocalHostname( oslSocketResult *pResult )
165  {
166  ::rtl::OUString hostname;
167  oslSocketResult result = osl_getLocalHostname( &(hostname.pData) );
168  if(pResult )
169  *pResult = result;
170  return hostname;
171  }
172 
173  inline void SAL_CALL SocketAddr::resolveHostname(
174  const ::rtl::OUString & strHostName, SocketAddr &Addr)
175  {
176  Addr = SocketAddr( osl_resolveHostname( strHostName.pData ) , SAL_NO_COPY );
177  }
178 
179  inline sal_Int32 SAL_CALL SocketAddr::getServicePort(
180  const ::rtl::OUString& strServiceName,
181  const ::rtl::OUString & strProtocolName )
182  {
183  return osl_getServicePort( strServiceName.pData, strProtocolName.pData );
184  }
185 
186 
188  oslAddrFamily Family,
189  oslProtocol Protocol)
190  : m_handle( osl_createSocket(Family, Type, Protocol) )
191  {}
192 
193 
194  inline Socket::Socket( oslSocket socketHandle, __sal_NoAcquire )
195  : m_handle( socketHandle )
196  {}
197 
198 
199  inline Socket::Socket( oslSocket socketHandle )
200  : m_handle( socketHandle )
201  {
203  }
204 
205 
206  inline Socket::Socket( const Socket & socket )
207  : m_handle( socket.getHandle() )
208  {
210  }
211 
212 
214  {
216  }
217 
218 
219  inline Socket& Socket::operator= ( oslSocket socketHandle)
220  {
221  osl_acquireSocket( socketHandle );
223  m_handle = socketHandle;
224  return *this;
225  }
226 
227 
228  inline Socket& Socket::operator= (const Socket& sock)
229  {
230  *this = sock.getHandle();
231  return *this;
232  }
233 
234 
235  inline bool Socket::operator==( const Socket& rSocket ) const
236  {
237  return m_handle == rSocket.getHandle();
238  }
239 
240 
241  inline bool Socket::operator==( const oslSocket socketHandle ) const
242  {
243  return m_handle == socketHandle;
244  }
245 
246 
247  inline void Socket::shutdown( oslSocketDirection Direction )
248  {
249  osl_shutdownSocket( m_handle , Direction );
250  }
251 
252 
253  inline void Socket::close()
254  {
256  }
257 
258 
259  inline void Socket::getLocalAddr( SocketAddr & addr) const
260  {
262  }
263 
264 
265  inline sal_Int32 Socket::getLocalPort() const
266  {
267  SocketAddr addr( NULL );
268  getLocalAddr( addr );
269  return addr.getPort();
270  }
271 
272 
273  inline ::rtl::OUString Socket::getLocalHost() const
274  {
275  SocketAddr addr( NULL );
276  getLocalAddr( addr );
277  return addr.getHostname();
278  }
279 
280 
281  inline void Socket::getPeerAddr( SocketAddr &addr ) const
282  {
284  }
285 
286 
287  inline sal_Int32 Socket::getPeerPort() const
288  {
289  SocketAddr addr( NULL );
290  getPeerAddr( addr );
291  return addr.getPort();
292  }
293 
294 
295  inline ::rtl::OUString Socket::getPeerHost() const
296  {
297  SocketAddr addr( NULL );
298  getPeerAddr( addr );
299  return addr.getHostname();
300  }
301 
302 
303  inline bool Socket::bind(const SocketAddr& LocalInterface)
304  {
305  return osl_bindAddrToSocket( m_handle , LocalInterface.getHandle() );
306  }
307 
308 
309  inline bool Socket::isRecvReady(const TimeValue *pTimeout ) const
310  {
311  return osl_isReceiveReady( m_handle , pTimeout );
312  }
313 
314 
315  inline bool Socket::isSendReady(const TimeValue *pTimeout ) const
316  {
317  return osl_isSendReady( m_handle, pTimeout );
318  }
319 
320 
321  inline bool Socket::isExceptionPending(const TimeValue *pTimeout ) const
322  {
323  return osl_isExceptionPending( m_handle, pTimeout );
324  }
325 
326 
328  {
329  return osl_getSocketType( m_handle );
330  }
331 
332 
333  inline sal_Int32 Socket::getOption(
334  oslSocketOption Option,
335  void* pBuffer,
336  sal_uInt32 BufferLen,
337  oslSocketOptionLevel Level) const
338  {
339  return osl_getSocketOption( m_handle, Level, Option, pBuffer , BufferLen );
340  }
341 
342 
343  inline bool Socket::setOption( oslSocketOption Option,
344  void* pBuffer,
345  sal_uInt32 BufferLen,
346  oslSocketOptionLevel Level ) const
347  {
348  return osl_setSocketOption( m_handle, Level, Option , pBuffer, BufferLen );
349  }
350 
351 
352  inline bool Socket::setOption( oslSocketOption option, sal_Int32 nValue )
353  {
354  return setOption( option, &nValue, sizeof( nValue ) );
355  }
356 
357 
358  inline sal_Int32 Socket::getOption( oslSocketOption option ) const
359  {
360  sal_Int32 n;
361  getOption( option, &n, sizeof( n ) );
362  return n;
363  }
364 
365 
366  inline bool Socket::enableNonBlockingMode( bool bNonBlockingMode)
367  {
368  return osl_enableNonBlockingMode( m_handle , bNonBlockingMode );
369  }
370 
371 
372  inline bool Socket::isNonBlockingMode() const
373  {
375  }
376 
377 
378  inline void SAL_CALL Socket::clearError() const
379  {
380  sal_Int32 err = 0;
381  getOption(osl_Socket_OptionError, &err, sizeof(err));
382  }
383 
384 
386  {
388  }
389 
390 
391  inline ::rtl::OUString Socket::getErrorAsString( ) const
392  {
393  ::rtl::OUString error;
395  return error;
396  }
397 
398 
400  {
401  return m_handle;
402  }
403 
404 
406  oslProtocol Protocol,
407  oslSocketType Type )
408  : Socket( Type, Family, Protocol )
409  {}
410 
411 
412  inline StreamSocket::StreamSocket( oslSocket socketHandle, __sal_NoAcquire noacquire )
413  : Socket( socketHandle, noacquire )
414  {}
415 
416 
417  inline StreamSocket::StreamSocket( oslSocket socketHandle )
418  : Socket( socketHandle )
419  {}
420 
421 
422  inline sal_Int32 StreamSocket::read(void* pBuffer, sal_uInt32 n)
423  {
424  return osl_readSocket( m_handle, pBuffer, n );
425  }
426 
427 
428  inline sal_Int32 StreamSocket::write(const void* pBuffer, sal_uInt32 n)
429  {
430  return osl_writeSocket( m_handle, pBuffer, n );
431  }
432 
433 
434  inline sal_Int32 StreamSocket::recv(void* pBuffer,
435  sal_uInt32 BytesToRead,
436  oslSocketMsgFlag Flag)
437  {
438  return osl_receiveSocket( m_handle, pBuffer,BytesToRead, Flag );
439  }
440 
441 
442  inline sal_Int32 StreamSocket::send(const void* pBuffer,
443  sal_uInt32 BytesToSend,
444  oslSocketMsgFlag Flag)
445  {
446  return osl_sendSocket( m_handle, pBuffer, BytesToSend, Flag );
447  }
448 
449 
451  oslProtocol Protocol,
452  oslSocketType Type)
453  : StreamSocket( Family, Protocol ,Type )
454  {}
455 
456 
458  const TimeValue* pTimeout )
459  {
460  return osl_connectSocketTo( m_handle , TargetHost.getHandle(), pTimeout );
461  }
462 
463 
465  oslProtocol Protocol ,
466  oslSocketType Type )
467  : Socket( Type, Family, Protocol )
468  {}
469 
470 
471  inline bool AcceptorSocket::listen(sal_Int32 MaxPendingConnections)
472  {
473  return osl_listenOnSocket( m_handle, MaxPendingConnections );
474  }
475 
476 
478  {
481  if( o )
482  {
483  Connection = StreamSocket( o , SAL_NO_ACQUIRE );
484  }
485  else
486  {
487  Connection = StreamSocket();
488  status = osl_Socket_Error;
489  }
490  return status;
491  }
492 
493 
495  StreamSocket& Connection, SocketAddr & PeerAddr)
496  {
497  // TODO change in/OUT parameter
499  m_handle, reinterpret_cast<oslSocketAddr *>(&PeerAddr));
501  if( o )
502  {
503  Connection = StreamSocket( o , SAL_NO_ACQUIRE );
504  }
505  else
506  {
507  Connection = StreamSocket();
508  status = osl_Socket_Error;
509  }
510  return status;
511  }
512 
513 
515  oslProtocol Protocol,
516  oslSocketType Type)
517  : Socket( Type, Family, Protocol )
518  {}
519 
520 
521  inline sal_Int32 DatagramSocket::recvFrom(void* pBuffer,
522  sal_uInt32 BufferSize,
523  SocketAddr* pSenderAddr,
524  oslSocketMsgFlag Flag )
525  {
526  sal_Int32 nByteRead;
527  if( pSenderAddr )
528  {
529  // TODO : correct the out-parameter pSenderAddr outparameter
530  nByteRead = osl_receiveFromSocket( m_handle, pSenderAddr->getHandle() , pBuffer,
531  BufferSize, Flag);
532  }
533  else
534  {
535  nByteRead = osl_receiveFromSocket( m_handle, NULL , pBuffer , BufferSize , Flag );
536  }
537  return nByteRead;
538  }
539 
540 
541  inline sal_Int32 DatagramSocket::sendTo( const SocketAddr& ReceiverAddr,
542  const void* pBuffer,
543  sal_uInt32 BufferSize,
544  oslSocketMsgFlag Flag )
545  {
546  return osl_sendToSocket( m_handle, ReceiverAddr.getHandle(), pBuffer, BufferSize, Flag );
547  }
548 }
549 #endif
550 
551 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ConnectorSocket(oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp, oslSocketType Type=osl_Socket_TypeStream)
Creates a socket that can connect to a (remote) host.
Definition: socket.hxx:450
SAL_DLLPUBLIC sal_Int32 osl_readSocket(oslSocket Socket, void *pBuffer, sal_Int32 nSize)
Retrieves n bytes from the stream and copies them into pBuffer.
bool operator==(const Socket &rSocket) const
Definition: socket.hxx:235
SAL_DLLPUBLIC oslSocketError osl_getLastSocketError(oslSocket Socket)
Returns a constant describing the last error for the socket system.
oslSocketMsgFlag
Represents flags to be used with send/recv-calls.
Definition: socket.h:115
SAL_DLLPUBLIC oslSocketAddr osl_getPeerAddrOfSocket(oslSocket Socket)
Retrieves the Address of the remote end of the socket.
bool listen(sal_Int32 MaxPendingConnections=-1)
Prepare a socket for the accept-call.
Definition: socket.hxx:471
SAL_DLLPUBLIC void osl_closeSocket(oslSocket Socket)
Closes the socket terminating any ongoing dataflow.
Socket & operator=(oslSocket socketHandle)
Assignment operator.
Definition: socket.hxx:219
void getPeerAddr(SocketAddr &Addr) const
Retrieves the address of the remote host of this socket.
Definition: socket.hxx:281
oslAddrFamily
Represents the address-family of a socket.
Definition: socket.h:29
oslSocketOptionLevel
Represents the different socket-option levels.
Definition: socket.h:105
Time since Jan-01-1970.
Definition: time.h:56
sal_Int32 recv(void *pBuffer, sal_uInt32 BytesToRead, oslSocketMsgFlag flags=osl_Socket_MsgNormal)
Tries to receive BytesToRead data from the connected socket,.
Definition: socket.hxx:434
SAL_DLLPUBLIC void osl_getLastSocketErrorDescription(oslSocket Socket, rtl_uString **strError)
returns a string which describes the last socket error.
SAL_DLLPUBLIC sal_Bool osl_setSocketOption(oslSocket Socket, oslSocketOptionLevel Level, oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen)
Sets the sockets attributes.
SAL_DLLPUBLIC oslSocketAddr osl_createEmptySocketAddr(oslAddrFamily Family)
Creates a socket-address for the given family.
SAL_DLLPUBLIC oslSocketAddr osl_copySocketAddr(oslSocketAddr Addr)
Creates a new SocketAddress and fills it from Addr.
SAL_DLLPUBLIC sal_Int32 osl_getSocketOption(oslSocket Socket, oslSocketOptionLevel Level, oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen)
Retrieves attributes associated with the socket.
SAL_DLLPUBLIC oslSocketAddr osl_getLocalAddrOfSocket(oslSocket Socket)
Retrieves the Address of the local end of the socket.
void shutdown(oslSocketDirection Direction=osl_Socket_DirReadWrite)
Closes a definite or both directions of the bidirectional stream.
Definition: socket.hxx:247
SAL_DLLPUBLIC void osl_releaseSocket(oslSocket Socket)
decreases the refcount of the socket handle by one.
oslSocketResult acceptConnection(StreamSocket &Connection)
Accepts incoming connections on the socket.
Definition: socket.hxx:477
SAL_DLLPUBLIC sal_Bool osl_isExceptionPending(oslSocket Socket, const TimeValue *pTimeout)
Checks if a request for out-of-band data will block.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
sal_Int32 write(const void *pBuffer, sal_uInt32 n)
Writes n bytes from pBuffer to the stream.
Definition: socket.hxx:428
inline::rtl::OUString getLocalHost() const
Get the hostname for the local interface.
Definition: socket.hxx:273
oslSocketError
Describes the various error socket error conditions, which may occur.
Definition: socket.h:138
__sal_NoAcquire
Definition: types.h:332
SAL_DLLPUBLIC oslSocketType osl_getSocketType(oslSocket Socket)
Queries the socket for its type.
SAL_DLLPUBLIC sal_Bool osl_bindAddrToSocket(oslSocket Socket, oslSocketAddr Addr)
Binds the given address to the socket.
oslSocketAddr m_handle
Definition: socket_decl.hxx:26
sal_Int32 sendTo(const SocketAddr &ReceiverAddr, const void *pBuffer, sal_uInt32 BufferSize, oslSocketMsgFlag Flag=osl_Socket_MsgNormal)
Tries to send one datagram with BytesToSend size to the given ReceiverAddr.
Definition: socket.hxx:541
static sal_Int32 getServicePort(const ::rtl::OUString &strServiceName, const ::rtl::OUString &strProtocolName=::rtl::OUString("tcp"))
Tries to find the port associated with the given service/protocol- pair (e.g.
Definition: socket.hxx:179
bool setPort(sal_Int32 nPort)
Sets the port number of the address.
Definition: socket.hxx:84
SAL_DLLPUBLIC sal_Bool osl_listenOnSocket(oslSocket Socket, sal_Int32 MaxPendingConnections)
Prepares the socket to act as an acceptor of incoming connections.
SAL_DLLPUBLIC sal_Bool osl_isSendReady(oslSocket Socket, const TimeValue *pTimeout)
Checks if send operations will block.
SAL_DLLPUBLIC oslSocketResult osl_getLocalHostname(rtl_uString **strLocalHostname)
Retrieve this machines hostname (NOT the FQDN)
SAL_DLLPUBLIC sal_Bool osl_isNonBlockingMode(oslSocket Socket)
Query state of non-blocking-mode of the socket.
bool is() const
Checks if the SocketAddr was created successful.
Definition: socket.hxx:159
bool setAddr(const ::rtl::ByteSequence &address)
Sets the address of the underlying socket address struct in network byte order.
Definition: socket.hxx:96
SAL_DLLPUBLIC sal_Bool osl_isEqualSocketAddr(oslSocketAddr Addr1, oslSocketAddr Addr2)
Compares the values of two SocketAddresses.
DatagramSocket(oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp, oslSocketType Type=osl_Socket_TypeDgram)
Creates a datagram socket.
Definition: socket.hxx:514
SocketAddr()
Creates socket address of unknown type.
Definition: socket.hxx:12
SAL_DLLPUBLIC sal_Int32 osl_receiveSocket(oslSocket Socket, void *pBuffer, sal_uInt32 BytesToRead, oslSocketMsgFlag Flag)
Tries to receive BytesToRead data from the connected socket, if no error occurs.
oslSocketResult
Common return codes of socket related functions.
Definition: socket.h:177
SAL_DLLPUBLIC sal_Int32 osl_receiveFromSocket(oslSocket Socket, oslSocketAddr SenderAddr, void *pBuffer, sal_uInt32 BufferSize, oslSocketMsgFlag Flag)
Tries to receives BufferSize data from the (usually unconnected) (datagram-)socket, if no error occurs.
SAL_DLLPUBLIC oslSocketAddr osl_resolveHostname(rtl_uString *strHostname)
Uses the systems name-service interface to find an address for strHostname.
Definition: socket_decl.hxx:512
oslSocket getHandle() const
Returns the underlying handle unacquired (The caller must acquire it to keep it). ...
Definition: socket.hxx:399
sal_Int32 recvFrom(void *pBuffer, sal_uInt32 BufferSize, SocketAddr *pSenderAddr=NULL, oslSocketMsgFlag Flag=osl_Socket_MsgNormal)
Tries to receives BufferSize data from the socket, if no error occurs.
Definition: socket.hxx:521
SAL_DLLPUBLIC oslSocketResult osl_getAddrOfSocketAddr(oslSocketAddr Addr, sal_Sequence **ppByteSeq)
Returns the addr field in the struct sockaddr.
SAL_DLLPUBLIC oslSocketResult osl_connectSocketTo(oslSocket Socket, oslSocketAddr Addr, const TimeValue *pTimeout)
Connects the socket to the given address.
Definition: socket_decl.hxx:17
~SocketAddr()
destroys underlying oslSocketAddress
Definition: socket.hxx:61
SocketAddr & assign(oslSocketAddr Addr, __osl_socket_NoCopy nocopy)
Assigns the socket addr without copyconstructing it.
Definition: socket.hxx:139
pData
Definition: ustring.hxx:334
bool bind(const SocketAddr &LocalInterface)
Binds the socket to the specified (local) interface.
Definition: socket.hxx:303
inline::rtl::OUString getPeerHost() const
Get the hostname for the remote interface.
Definition: socket.hxx:295
inline::rtl::OUString getHostname(oslSocketResult *pResult=NULL) const
Converts the address to a (human readable) domain-name.
Definition: socket.hxx:68
SAL_DLLPUBLIC sal_Int32 osl_sendSocket(oslSocket Socket, const void *pBuffer, sal_uInt32 BytesToSend, oslSocketMsgFlag Flag)
Tries to send BytesToSend data from the connected socket, if no error occurs.
oslSocketDirection
Used by shutdown to denote which end of the socket to &quot;close&quot;.
Definition: socket.h:128
void close()
Closes a socket.
Definition: socket.hxx:253
The class should be understood as a reference to a socket address handle (struct sockaddr).
Definition: socket_decl.hxx:23
Definition: socket.h:94
inline::rtl::ByteSequence getAddr(oslSocketResult *pResult=NULL) const
Returns the address of the underlying socket in network byte order.
Definition: socket.hxx:102
void clearError() const
clears the error status
Definition: socket.hxx:378
SocketAddr & operator=(oslSocketAddr Addr)
assign the handle to this reference.
Definition: socket.hxx:112
definition of a no acquire enum for ctors
Definition: types.h:336
__osl_socket_NoCopy
Definition: socket_decl.hxx:17
void getLocalAddr(SocketAddr &Addr) const
Retrieves the address of the local interface of this socket.
Definition: socket.hxx:259
bool setOption(oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level=osl_Socket_LevelSocket) const
Sets the sockets attributes.
Definition: socket.hxx:343
SAL_DLLPUBLIC void osl_acquireSocket(oslSocket Socket)
increases the refcount of the socket handle by one
oslSocketResult connect(const SocketAddr &TargetHost, const TimeValue *pTimeout=NULL)
Connects the socket to a (remote) host.
Definition: socket.hxx:457
SAL_DLLPUBLIC oslSocket osl_createSocket(oslAddrFamily Family, oslSocketType Type, oslProtocol Protocol)
Create a socket of the specified Family and Type.
sal_Int32 getPeerPort() const
Get the remote port of the socket.
Definition: socket.hxx:287
SAL_DLLPUBLIC void osl_destroySocketAddr(oslSocketAddr Addr)
Frees all resources allocated by Addr.
sal_Int32 getOption(oslSocketOption Option, void *pBuffer, sal_uInt32 BufferLen, oslSocketOptionLevel Level=osl_Socket_LevelSocket) const
Retrieves option-attributes associated with the socket.
Definition: socket.hxx:333
inline::rtl::OUString getErrorAsString() const
Builds a string with the last error-message for the socket.
Definition: socket.hxx:391
sal_Int32 send(const void *pBuffer, sal_uInt32 BytesToSend, oslSocketMsgFlag=osl_Socket_MsgNormal)
Tries to send BytesToSend data to the connected socket.
Definition: socket.hxx:442
static inline::rtl::OUString getLocalHostname(oslSocketResult *pResult=NULL)
Get the hostname for the local interface.
Definition: socket.hxx:164
struct oslSocketAddrImpl * oslSocketAddr
Opaque datatype SocketAddr.
Definition: socket.h:24
oslSocketError getError() const
returns a constant describing the last error for the socket system.
Definition: socket.hxx:385
SAL_DLLPUBLIC oslSocketResult osl_getHostnameOfSocketAddr(oslSocketAddr Addr, rtl_uString **strHostname)
Returns the hostname represented by Addr.
SAL_DLLPUBLIC oslSocketResult osl_setAddrOfSocketAddr(oslSocketAddr Addr, sal_Sequence *pByteSeq)
Sets the addr field in the struct sockaddr with pByteSeq.
sal_Int32 read(void *pBuffer, sal_uInt32 n)
Retrieves n bytes from the stream and copies them into pBuffer.
Definition: socket.hxx:422
bool isSendReady(const TimeValue *pTimeout=NULL) const
Checks if send operations will block.
Definition: socket.hxx:315
sal_Int32 getPort() const
Returns the port number of the address.
Definition: socket.hxx:78
C++ class representing a SAL byte sequence.
Definition: byteseq.h:149
SAL_DLLPUBLIC sal_Bool osl_shutdownSocket(oslSocket Socket, oslSocketDirection Direction)
Shuts down communication on a connected socket.
SAL_DLLPUBLIC sal_Int32 osl_sendToSocket(oslSocket Socket, oslSocketAddr ReceiverAddr, const void *pBuffer, sal_uInt32 BytesToSend, oslSocketMsgFlag Flag)
Tries to send one datagram with BytesToSend data to the given ReceiverAddr via the (implicitly unconn...
bool enableNonBlockingMode(bool bNonBlockingMode)
Enables/disables non-blocking mode of the socket.
Definition: socket.hxx:366
SAL_DLLPUBLIC sal_Bool osl_isReceiveReady(oslSocket Socket, const TimeValue *pTimeout)
Checks if read operations will block.
bool setHostname(const ::rtl::OUString &sDottedIpOrHostname)
Sets the IP address or hostname of the SocketAddress.
Definition: socket.hxx:89
AcceptorSocket(oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp, oslSocketType Type=osl_Socket_TypeStream)
Definition: socket.hxx:464
Definition: socket.h:178
StreamSocket(oslAddrFamily Family=osl_Socket_FamilyInet, oslProtocol Protocol=osl_Socket_ProtocolIp, oslSocketType Type=osl_Socket_TypeStream)
Creates a socket.
Definition: socket.hxx:405
oslSocketOption
Represents socket-options.
Definition: socket.h:69
SAL_DLLPUBLIC sal_Int32 osl_getServicePort(rtl_uString *strServicename, rtl_uString *strProtocol)
Looks up the port-number designated to the specified service/protocol-pair.
oslSocketType getType() const
Queries the socket for its type.
Definition: socket.hxx:327
bool operator==(oslSocketAddr Addr) const
Returns true if the underlying handle is identical to the Addr handle.
Definition: socket.hxx:148
Definition: socket.h:30
sal_Int32 getLocalPort() const
Get the local port of the socket.
Definition: socket.hxx:265
SAL_DLLPUBLIC sal_Bool osl_enableNonBlockingMode(oslSocket Socket, sal_Bool On)
Enables/disables non-blocking-mode of the socket.
oslSocketType
Represents the type of a socket.
Definition: socket.h:51
SAL_DLLPUBLIC sal_Int32 osl_getInetPortOfSocketAddr(oslSocketAddr Addr)
Retrieves the internet port-number of Addr.
SAL_DLLPUBLIC sal_Bool osl_setInetPortOfSocketAddr(oslSocketAddr Addr, sal_Int32 Port)
Sets the Port of Addr.
oslProtocol
represent a specific protocol within an address-family
Definition: socket.h:39
Definition: socket_decl.hxx:177
SAL_DLLPUBLIC sal_Int32 osl_writeSocket(oslSocket Socket, const void *pBuffer, sal_Int32 nSize)
Writes n bytes from pBuffer to the stream.
bool isExceptionPending(const TimeValue *pTimeout=NULL) const
Checks if a request for out-of-band data will block.
Definition: socket.hxx:321
struct oslSocketImpl * oslSocket
Definition: socket.h:195
static void resolveHostname(const ::rtl::OUString &strHostName, SocketAddr &Addr)
Tries to find an address for a host.
Definition: socket.hxx:173
SAL_DLLPUBLIC oslSocketAddr osl_createInetSocketAddr(rtl_uString *strDottedAddr, sal_Int32 Port)
Create an internet-address, consisting of host address and port.
bool isNonBlockingMode() const
Query blocking mode of the socket.
Definition: socket.hxx:372
Definition: socket.h:179
bool isRecvReady(const TimeValue *pTimeout=NULL) const
Checks if read operations will block.
Definition: socket.hxx:309
~Socket()
Destructor.
Definition: socket.hxx:213
SAL_DLLPUBLIC oslSocket osl_acceptConnectionOnSocket(oslSocket Socket, oslSocketAddr *pAddr)
Waits for an ingoing connection on the socket.
oslSocketAddr getHandle() const
Returns the underlying SocketAddr handle without copyconstructing it.
Definition: socket.hxx:153
oslSocket m_handle
Definition: socket_decl.hxx:180