update dev300-m58
[ooovba.git] / sal / inc / osl / socket_decl.hxx
blob7bf558f919259dcfd80727db53f502c554c9c617
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: socket_decl.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OSL_SOCKET_DECL_HXX_
32 #define _OSL_SOCKET_DECL_HXX_
34 #include <osl/socket.h>
35 #include <rtl/ustring.hxx>
36 #include <rtl/byteseq.hxx>
38 /** @HTML
40 namespace osl
42 enum __osl_socket_NoCopy { SAL_NO_COPY };
44 /** The class should be understood as a reference to a socket address handle ( struct sockaddr ).
46 The handle is mutable.
48 class SocketAddr
50 protected:
51 oslSocketAddr m_handle;
52 public:
54 /** Creates socket address of unknown type.
56 inline SocketAddr();
58 /** Copy constructor.
60 inline SocketAddr(const SocketAddr& Addr);
62 /** The SocketAddr takes over the responsibility of the handle ( which means,
63 that the handle gets destructed by the destructor of this reference)
65 @param nocopy use SAL_NO_COPY
67 inline SocketAddr(const oslSocketAddr , __osl_socket_NoCopy nocopy );
69 /** Copyconstructs the oslSocketAddr handle.
71 inline SocketAddr(oslSocketAddr Addr);
73 /** tcpip-specif constructor.
74 @param strAddrOrHostName strAddrOrHostName hostname or dotted ip-number of the network
75 interface, the socket shall be created on.
76 @param nPort tcp-ip port number
78 inline SocketAddr( const ::rtl::OUString& strAddrOrHostName, sal_Int32 nPort );
80 /** destroys underlying oslSocketAddress
82 inline ~SocketAddr();
84 /** checks, if the SocketAddr was created successful.
85 @return <code>sal_True</code> if there is a valid underlying handle,
86 otherwise sal_False.
88 inline sal_Bool is() const;
90 /** Converts the address to a (human readable) domain-name.
92 @param pResult 0, if you are not interested in errors,
93 otherwise *pResult contains an error code on failure
94 or osl_Socket_Ok on success
95 @return the hostname of this SocketAddr or an empty string on failure.
96 @see osl_getHostnameOfSocketAddr()
98 inline ::rtl::OUString SAL_CALL getHostname( oslSocketResult *pResult = 0 ) const;
100 /** Sets the ipaddress or hostname of the SocketAddress
102 inline sal_Bool SAL_CALL setHostname( const ::rtl::OUString &sDottedIpOrHostname );
104 /** Returns the port number of the address.
105 @return the port in host-byte order or or OSL_INVALID_PORT on errors.
107 inline sal_Int32 SAL_CALL getPort() const;
109 /** Sets the port number of the address.
110 @return true if successfule.
112 inline sal_Bool SAL_CALL setPort( sal_Int32 nPort );
114 /** Sets the address of the underlying socket address struct in network byte order.
115 @return true on success, false signales falure.
117 inline sal_Bool SAL_CALL setAddr( const ::rtl::ByteSequence & address );
119 /** Returns the address of the underlying socket in network byte order
121 inline ::rtl::ByteSequence SAL_CALL getAddr( oslSocketResult *pResult = 0 ) const;
123 /** assign the handle to this reference. The previous handle is released.
125 inline SocketAddr & SAL_CALL operator= (oslSocketAddr Addr);
127 /**
129 inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr);
131 /** Assigns the socket addr without copyconstructing it.
132 @param nocopy use SAL_NO_COPY
134 inline SocketAddr & SAL_CALL assign( oslSocketAddr Addr, __osl_socket_NoCopy nocopy );
136 /** Returns true if the underlying handle is identical to the Addr handle.
138 inline sal_Bool SAL_CALL operator== (oslSocketAddr Addr) const;
140 /** Returns true if the underlying handle is identical to the Addr handle.
142 inline sal_Bool SAL_CALL operator== (const SocketAddr & Addr) const;
144 /** Returns the underlying SocketAddr handle without copyconstructing it.
146 inline oslSocketAddr SAL_CALL getHandle() const;
148 /** Get the hostname for the local interface.
149 @param after the call *pResult contains osl_Socket_Ok on success or
150 an error on failure.
151 @return the hostname
153 static inline ::rtl::OUString SAL_CALL getLocalHostname( oslSocketResult *pResult = 0);
155 /** Tries to find an address for a host.
156 @see osl_resolveHostname()
157 @return A new created socket-address or 0 if the name could not be found.
159 static inline void SAL_CALL resolveHostname(
160 const ::rtl::OUString & strHostName , SocketAddr & Addr );
163 Tries to find the port associated with the given service/protocol-
164 pair (e.g. "ftp"/"tcp").
165 @return the port number in host-byte order or <code>OSL_INVALID_PORT</code>
166 if no service/protocol pair could be found.
168 static inline sal_Int32 SAL_CALL getServicePort(
169 const ::rtl::OUString& strServiceName,
170 const ::rtl::OUString & strProtocolName= ::rtl::OUString::createFromAscii( "tcp" ) );
174 class Socket
176 protected:
177 oslSocket m_handle;
178 protected:
179 /** Creates a socket. Note it's protected.
180 @param Type
181 @param Family
182 @param Protocol
184 inline Socket(oslSocketType Type,
185 oslAddrFamily Family = osl_Socket_FamilyInet,
186 oslProtocol Protocol = osl_Socket_ProtocolIp);
187 public:
188 inline Socket( );
190 inline Socket( const Socket & socket );
192 inline Socket( oslSocket socketHandle );
194 /** The instance takes over the handle's ownership without acquiring the
195 handle, but releases it within the dtor.
196 @param noacquire use SAL_NO_ACQUIRE
198 inline Socket( oslSocket socketHandle, __sal_NoAcquire noacquire );
200 /** Destructor. Releases the underlying handle
202 inline ~Socket();
204 /** Assignment operator. If socket was already created, the old one will
205 be discarded.
207 inline Socket& SAL_CALL operator= ( oslSocket socketHandle);
209 /** Assignment operator. If socket was already created, the old one will
210 be discarded.
212 inline Socket& SAL_CALL operator= (const Socket& sock);
214 /**
215 @return <code>sal_True</code>, when the underlying handle of both
216 Socket instances are identical, <code>sal_False</code> otherwise.
218 inline sal_Bool SAL_CALL operator==( const Socket& rSocket ) const ;
220 /**
221 @return <code>sal_True</code>, when the underlying handle of both
222 Socket instances are identical, <code>sal_False</code> otherwise.
224 inline sal_Bool SAL_CALL operator==( const oslSocket socketHandle ) const;
226 /** Closes a definite or both directions of the bidirectional stream.
228 @param Direction
229 @see osl_shutdownSocket()
231 inline void SAL_CALL shutdown( oslSocketDirection Direction = osl_Socket_DirReadWrite );
233 /** Closes a socket.
234 Note that closing a socket is identical to shutdown( osl_Socket_DirReadWrite ),
235 as the operating system distinguish both cases, both functions or offered in this API.
236 @see osl_closeSocket()
238 inline void SAL_CALL close();
240 /** Retrieves the address of the local interface of this socket.
241 @param Addr [out] receives the address.
242 @see osl_getLocalAddrOfSocket()
244 inline void SAL_CALL getLocalAddr( SocketAddr &Addr ) const;
246 /** Get the local port of the socket. Usually used after bind().
247 @return the port number or OSL_INVALID_PORT on errors.
249 inline sal_Int32 SAL_CALL getLocalPort() const;
251 /** Get the hostname for the local interface.
252 @return the hostname or an empty string ("").
254 inline ::rtl::OUString SAL_CALL getLocalHost() const;
256 /** Retrieves the address of the remote host of this socket.
257 @param Addr [out] receives the address.
259 inline void SAL_CALL getPeerAddr( SocketAddr & Addr) const;
261 /** Get the remote port of the socket.
262 @return the port number or OSL_INVALID_PORT on errors.
264 inline sal_Int32 SAL_CALL getPeerPort() const;
266 /** Get the hostname for the remote interface.
267 @return the hostname or an empty string ("").
269 inline ::rtl::OUString SAL_CALL getPeerHost() const;
271 /** Binds the socket to the specified (local) interface.
272 @param LocalInterface Address of the Interface
273 @return True if bind was successful.
275 inline sal_Bool SAL_CALL bind(const SocketAddr& LocalInterface);
277 /** Checks if read operations will block.
279 You can specify a timeout-value in seconds/nanoseconds that denotes
280 how the operation will block if the Socket is not ready.
281 @return <code>sal_True</code> if read operations (recv, recvFrom, accept) on the Socket
282 will NOT block; <code>sal_False</code> if it would block or if an error occured.
284 @param pTimeout if 0, the operation will block without a timeout. Otherwise
285 the specified amout of time.
287 inline sal_Bool SAL_CALL isRecvReady(const TimeValue *pTimeout = 0) const;
289 /** Checks if send operations will block.
291 You can specify a timeout-value in seconds/nanoseconds that denotes
292 how the operation will block if the Socket is not ready.
293 @return <code>sal_True</code> if send operations (send, sendTo) on the Socket
294 will NOT block; <code>sal_False</code> if it would block or if an error occured.
296 @param pTimeout if 0, the operation will block without a timeout. Otherwise
297 the specified amout of time.
299 inline sal_Bool SAL_CALL isSendReady(const TimeValue *pTimeout = 0) const;
302 /** Checks if a request for out-of-band data will block.
304 You can specify a timeout-value in seconds/nanoseconds that denotes
305 how the operation will block if the Socket has no pending OOB data.
307 @return <code>sal_True</code> if OOB-request operations (recv with appropriate flags)
308 on the Socket will NOT block; <code>sal_False</code> if it would block or if
309 an error occured.
311 @param pTimeout if 0, the operation will block without a timeout. Otherwise
312 the specified amout of time.
314 inline sal_Bool SAL_CALL isExceptionPending(const TimeValue *pTimeout = 0) const;
317 /** Queries the socket for its type.
318 @return one of:
319 <ul>
320 <li> <code>osl_Socket_TypeStream</code>
321 <li> <code>osl_Socket_TypeDgram</code>
322 <li> <code>osl_Socket_TypeRaw</code>
323 <li> <code>osl_Socket_TypeRdm</code>
324 <li> <code>osl_Socket_TypeSeqPacket</code>
325 <li> <code>osl_invalid_SocketType</code>, if an error occured
326 </ul>
328 inline oslSocketType SAL_CALL getType() const;
330 /** Retrieves option-attributes associated with the socket.
331 @param Option The attribute to query.
332 Valid values (depending on the Level) are:
333 <ul>
334 <li> <code>osl_Socket_Option_Debug</code><br>
335 (sal_Bool) Socket debug flag 1 = enabled, 0 = disabled.
337 <li> <code>osl_Socket_OptionAcceptConn</code><br>
338 <li> <code>osl_Socket_OptionReuseAddr</code><br>
339 (sal_Bool) Allows the socket to be bound to an address that is
340 already in use.
341 1 = multiple bound allowed, 0 = no multiple bounds allowed
343 <li><code>osl_Socket_OptionKeepAlive</code><br>
344 (sal_Bool) Keepalive packets are sent by the underlying socket.
345 1 = enabled, 0 = disabled
347 <li><code>osl_Socket_OptionDontRoute</code><br>
348 (sal_Bool) Do not route: send directly to interface.
349 1 = do not route , 0 = routing possible
351 <li><code>osl_Socket_OptionBroadcast</code><br>
352 (sal_Bool) Transmission of broadcast messages are allowed on the socket.
353 1 = transmission allowed, 0 = transmission disallowed
355 <li><code>osl_Socket_OptionUseLoopback</code><br>
357 <li><code>osl_Socket_OptionLinger</code><br>
358 (linger) Linger on close if unsent data is present.
359 linger has two members: l_onoff, l_linger
360 l_onoff = 0 is off, l_onoff > 0 and l_linger= timeout in seconds.
362 <li><code>osl_Socket_OptionOOBinLine</code><br>
365 <li><code>osl_Socket_OptionSndBuf</code><br>
366 (sal_Int32) Size of the send buffer in bytes. Data is sent after
367 SndTimeo or when the buffer is full. This allows faster writing
368 to the socket.
370 <li><code>osl_Socket_OptionRcvBuf</code><br>
371 (sal_Int32) Size of the receive buffer in bytes. Data is sent after
372 SndTimeo or when the buffer is full. This allows faster writing
373 to the socket and larger packet sizes.
375 <li><code>osl_Socket_OptionSndLowat</code><br>
377 <li><code>osl_Socket_OptionRcvLowat</code><br>
379 <li><code>osl_Socket_OptionSndTimeo</code><br>
380 (sal_Int32) Data is sent after this timeout. This allows gathering
381 of data to send larger packages but increases latency times.
383 <li><code>osl_Socket_OptionRcvTimeo</code><br>
385 <li><code>osl_Socket_OptionError</code><br>
386 <li><code>osl_Socket_OptionType</code><br>
388 <li><code>osl_Socket_OptionTcpNoDelay</code><br>
389 Disables the Nagle algorithm for send coalescing. (Do not
390 collect data until a packet is full, instead send immediatly.
391 This increases network traffic but might improve latency-times.)
392 1 = disables the algorithm, 0 = keeps it enabled.
393 </ul>
395 If not above mentioned otherwise, the options are only valid for
396 level <code>osl_Socket_LevelSocket</code>.
397 @param pBuffer The Buffer will be filled with the attribute.
399 @param BufferSize The size of pBuffer.
401 @param Level The option level.
403 Valid values are:
404 <ul>
405 <li><code>osl_Socket_LevelSocket</code> : Socket Level
406 <li><code>osl_Socket_LevelTcp</code> : Level of Transmission Control Protocol
407 </ul>
408 @return The size of the attribute copied into pBuffer or -1 if an error
409 occured.
411 inline sal_Int32 SAL_CALL getOption(
412 oslSocketOption Option,
413 void* pBuffer,
414 sal_uInt32 BufferLen,
415 oslSocketOptionLevel Level= osl_Socket_LevelSocket) const;
417 /** Sets the sockets attributes.
419 @param Option denotes the option to modify.
420 Valid values (depending on the Level) are:
421 <ul>
422 <li> osl_Socket_Option_Debug
423 <li> osl_Socket_OptionAcceptConn
424 <li> osl_Socket_OptionReuseAddr
425 <li> osl_Socket_OptionKeepAlive
426 <li> osl_Socket_OptionDontRoute
427 <li> osl_Socket_OptionBroadcast
428 <li> osl_Socket_OptionUseLoopback
429 <li> osl_Socket_OptionLinger
430 <li> osl_Socket_OptionOOBinLine
431 <li> osl_Socket_OptionSndBuf
432 <li> osl_Socket_OptionRcvBuf
433 <li> osl_Socket_OptionSndLowat
434 <li> osl_Socket_OptionRcvLowat
435 <li> osl_Socket_OptionSndTimeo
436 <li> osl_Socket_OptionRcvTimeo
437 <li> osl_Socket_OptionError
438 <li> osl_Socket_OptionType
439 <li> osl_Socket_OptionTcpNoDelay
440 </ul>
442 If not above mentioned otherwise, the options are only valid for
443 level osl_Socket_LevelSocket.
445 @param pBuffer Pointer to a Buffer which contains the attribute-value.
447 @param BufferSize contains the length of the Buffer.
449 @param Level selects the level for which an option should be changed.
450 Valid values are:
451 <ul>
452 <li> osl_Socket_evel_Socket : Socket Level
453 <li> osl_Socket_Level_Tcp : Level of Transmission Control Protocol
454 </ul>
456 @return True if the option could be changed.
458 inline sal_Bool SAL_CALL setOption( oslSocketOption Option,
459 void* pBuffer,
460 sal_uInt32 BufferLen,
461 oslSocketOptionLevel Level= osl_Socket_LevelSocket ) const;
463 /** Convenience function for setting sal_Bool and sal_Int32 option values.
464 @see setOption()
466 inline sal_Bool setOption( oslSocketOption option, sal_Int32 nValue );
468 /** Convenience function for retrieving sal_Bool and sal_Int32 option values.
469 @see setOption()
471 inline sal_Int32 getOption( oslSocketOption option ) const;
473 /** Enables/disables non-blocking mode of the socket.
474 @param bNonBlockingMode If <code>sal_True</code>, blocking mode will be switched off
475 If <code>sal_False</code>, the socket will become a blocking
476 socket (which is the default behaviour of a socket).
477 @return <code>sal_True</code> if mode could be set.
479 inline sal_Bool SAL_CALL enableNonBlockingMode( sal_Bool bNonBlockingMode);
481 /** Query blocking mode of the socket.
482 @return <code>sal_True</code> if non-blocking mode is set.
484 inline sal_Bool SAL_CALL isNonBlockingMode() const;
487 /** clears the error status
489 inline void SAL_CALL clearError() const;
491 /** returns a constant decribing the last error for the socket system.
493 @return osl_Socket_E_NONE if no error occured, invalid_SocketError if
494 an unknown (unmapped) error occured, otherwise an enum describing the
495 error.
496 @see osl_getLastSocketError()
498 inline oslSocketError getError() const;
500 /** Builds a string with the last error-message for the socket.
502 inline ::rtl::OUString getErrorAsString( ) const;
504 /** Returns the underlying handle unacquired (The caller must acquire it to keep it).
506 inline oslSocket getHandle() const;
510 class StreamSocket : public Socket
512 public:
513 /** Creates a socket.
514 @param Type For some protocols it might be desirable to
515 use a different type than <code>osl_Socket_TypeStream</code>
516 (like <code>osl_Socket_TypeSeqPacket</code>).
517 Therefore this parameter is not hidden.
519 inline StreamSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
520 oslProtocol Protocol = osl_Socket_ProtocolIp,
521 oslSocketType Type = osl_Socket_TypeStream);
523 inline StreamSocket( const StreamSocket & );
525 inline StreamSocket( oslSocket Socket , __sal_NoAcquire noacquire );
527 inline StreamSocket( oslSocket Socket );
529 /** Retrieves n bytes from the stream and copies them into pBuffer.
530 The method avoids incomplete reads due to packet boundaries and is thus
531 blocking.
532 @param pBuffer receives the read data. pBuffer must be large enough
533 to hold n bytes.
534 @param n the number of bytes to read.
535 @return the number of read bytes. The number will only be smaller than
536 n if an exceptional condition (e.g. connection closed) occurs.
538 inline sal_Int32 SAL_CALL read(void* pBuffer, sal_uInt32 n);
540 /** Writes n bytes from pBuffer to the stream. The method avoids
541 incomplete writes due to packet boundaries and is thus blocking.
542 @param pBuffer contains the data to be written.
543 @param n the number of bytes to write.
544 @return the number of written bytes. The number will only be smaller than
545 n if an exceptional condition (e.g. connection closed) occurs.
547 inline sal_Int32 SAL_CALL write(const void* pBuffer, sal_uInt32 n);
550 /** Tries to receive BytesToRead data from the connected socket,
552 @param pBuffer [out] Points to a buffer that will be filled with the received
553 data. pBuffer must have at least have a size of BytesToRead.
554 @param BytesToRead [in] The number of bytes to read.
555 @param Flag [in] Modifier for the call. Valid values are:
557 <ul>
558 <li><code>osl_Socket_MsgNormal</code>
559 <li><code>osl_Socket_MsgOOB</code>
560 <li><code>osl_Socket_MsgPeek</code>
561 <li><code>osl_Socket_MsgDontRoute</code>
562 <li><code>osl_Socket_MsgMaxIOVLen</code>
563 </ul>
564 @return the number of received bytes, which may be less than BytesToRead.
566 inline sal_Int32 SAL_CALL recv(void* pBuffer,
567 sal_uInt32 BytesToRead,
568 oslSocketMsgFlag flags= osl_Socket_MsgNormal);
570 /** Tries to send BytesToSend data to the connected socket.
572 @param pBuffer [in] Points to a buffer that contains the send-data.
573 @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
574 this size.
575 @param Flag [in] Modifier for the call. Valid values are:
576 <ul>
577 <li><code>osl_Socket_MsgNormal</code>
578 <li><code>osl_Socket_MsgOOB</code>
579 <li><code>osl_Socket_MsgPeek</code>
580 <li><code>osl_Socket_MsgDontRoute</code>
581 <li><code>osl_Socket_MsgMaxIOVLen</code>
582 </ul>
584 @return the number of transfered bytes. It may be less than BytesToSend.
586 sal_Int32 SAL_CALL send(const void* pBuffer,
587 sal_uInt32 BytesToSend,
588 oslSocketMsgFlag= osl_Socket_MsgNormal);
591 class ConnectorSocket : public StreamSocket
593 public:
594 /** Creates a socket that can connect to a (remote) host.
595 @param Type For some protocols it might be desirable to
596 use a different type than sock_stream <code>osl_Socket_TypeSeqPacket</code>
597 (like <code>osl_Socket_TypeSeqPacket</code>).
598 Therefore we do not hide this parameter here.
600 ConnectorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
601 oslProtocol Protocol = osl_Socket_ProtocolIp,
602 oslSocketType Type = osl_Socket_TypeStream);
605 /** Connects the socket to a (remote) host.
606 @param TargetHost The address of the target.
607 @param pTimeOut The timeout for blocking. If 0, a default system dependent timeout
608 us used.
609 @return <code> osl_Socket_Ok</code> if connected successfully,
610 <code>osl_Socket_TimedOut</code> on timeout,
611 <code>osl_Socket_Interrupted</code> if unblocked forcefully (by osl::Socket::close()),
612 <code>osl_Socket_Error</code> if connect failed.
614 oslSocketResult SAL_CALL connect(const SocketAddr& TargetHost, const TimeValue* pTimeout = 0);
617 /** Allows to accept socket connections.
619 class AcceptorSocket : public Socket
621 public:
622 inline AcceptorSocket(oslAddrFamily Family = osl_Socket_FamilyInet,
623 oslProtocol Protocol = osl_Socket_ProtocolIp,
624 oslSocketType Type = osl_Socket_TypeStream);
626 /** Prepare a socket for the accept-call. The socket must have been
627 bound before to the local address.
628 @param MaxPendingConnections The maximum number of pending
629 connections (waiting to be accepted) on this socket. If you use
630 -1, a system default value is used.
631 @return <code>sal_True</code> if call was successful.
633 inline sal_Bool SAL_CALL listen(sal_Int32 MaxPendingConnections= -1);
635 /** Accepts incoming connections on the socket. You must
636 precede this call with osl::Socket::bind() and listen().
637 @param Connection receives the incoming connection.
638 @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
639 <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
640 <code>osl_Socket_Error</code> on errors.
642 inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection);
644 /** Accepts incoming connections on the socket. You must
645 precede this call with osl::Socket::bind() and listen().
646 @param PeerAddr receives the address of the connecting entity
647 (your communication partner).
648 @param Connection receives the incoming connection.
649 @return <code>osl_Socket_Ok</code>, if a connection has been accepted,
650 <code>osl_Socket_TimedOut</code>, if m_RecvTimeout milliseconds passed without connect,
651 <code>osl_Socket_Error</code> on errors.
653 inline oslSocketResult SAL_CALL acceptConnection( StreamSocket& Connection, SocketAddr & PeerAddr);
658 /** A connectionless socket to send and receive datagrams.
660 class DatagramSocket : public Socket
662 public:
664 /** Creates a datagram socket.
665 @param Type is sock_dgram by default.
667 inline DatagramSocket(oslAddrFamily Family= osl_Socket_FamilyInet,
668 oslProtocol Protocol= osl_Socket_ProtocolIp,
669 oslSocketType Type= osl_Socket_TypeDgram);
671 /** Tries to receives BufferSize data from the socket, if no error occurs.
673 @param pSenderAddr [out] You must provide pointer to a SocketAddr.
674 It will be filled with the address of the datagrams sender.
675 If pSenderAddr is 0, it is ignored.
676 @param pBuffer [out] Points to a buffer that will be filled with the received
677 datagram.
678 @param BufferSize [in] The size of pBuffer.
679 @param Flag [in] Modifier for the call. Valid values are:
680 <ul>
681 <li><code>osl_Socket_MsgNormal</code>
682 <li><code>osl_Socket_MsgOOB</code>
683 <li><code>osl_Socket_MsgPeek</code>
684 <li><code>osl_Socket_MsgDontRoute</code>
685 <li><code>osl_Socket_MsgMaxIOVLen</code>
686 </ul>
688 @return the number of received bytes.
690 inline sal_Int32 SAL_CALL recvFrom(void* pBuffer,
691 sal_uInt32 BufferSize,
692 SocketAddr* pSenderAddr= 0,
693 oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
695 /** Tries to send one datagram with BytesToSend size to the given ReceiverAddr.
696 Since there is only send one packet, the function doesn't care about
697 packet boundaries.
699 @param ReceiverAddr [in] A SocketAddr that contains
700 the destination address for this send.
702 @param pBuffer [in] Points to a buffer that contains the send-data.
703 @param BufferSize [in] The number of bytes to send. pBuffer must have at least
704 this size.
705 @param Flag [in] Modifier for the call. Valid values are:
707 <ul>
708 <li><code>osl_Socket_MsgNormal</code>
709 <li><code>osl_Socket_MsgOOB</code>
710 <li><code>osl_Socket_MsgPeek</code>
711 <li><code>osl_Socket_MsgDontRoute</code>
712 <li><code>osl_Socket_MsgMaxIOVLen</code>
713 </ul>
715 @return the number of transfered bytes.
717 inline sal_Int32 SAL_CALL sendTo( const SocketAddr& ReceiverAddr,
718 const void* pBuffer,
719 sal_uInt32 BufferSize,
720 oslSocketMsgFlag Flag= osl_Socket_MsgNormal);
725 #endif