LibreOffice: osl/socket.hxx Source File

LibreOffice LibreOffice 5.3 SDK C/C++ API Reference

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