2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _DATAGRAM_SOCKET_H
6 #define _DATAGRAM_SOCKET_H
9 #include <AbstractSocket.h>
12 class BDatagramSocket
: public BAbstractSocket
{
15 BDatagramSocket(const BNetworkAddress
& peer
,
16 bigtime_t timeout
= -1);
17 BDatagramSocket(const BDatagramSocket
& other
);
18 virtual ~BDatagramSocket();
20 virtual status_t
Bind(const BNetworkAddress
& peer
,
21 bool reuseAddr
= true);
22 virtual status_t
Connect(const BNetworkAddress
& peer
,
23 bigtime_t timeout
= B_INFINITE_TIMEOUT
);
25 virtual status_t
Accept(BAbstractSocket
*& _socket
);
27 status_t
SetBroadcast(bool broadcast
);
28 void SetPeer(const BNetworkAddress
& peer
);
30 virtual size_t MaxTransmissionSize() const;
32 virtual ssize_t
SendTo(const BNetworkAddress
& address
,
33 const void* buffer
, size_t size
);
34 virtual ssize_t
ReceiveFrom(void* buffer
, size_t bufferSize
,
35 BNetworkAddress
& from
);
37 // BDataIO implementation
39 virtual ssize_t
Read(void* buffer
, size_t size
);
40 virtual ssize_t
Write(const void* buffer
, size_t size
);
44 #endif // _DATAGRAM_SOCKET_H