1 /* 2 * Copyright 2011, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DATAGRAM_SOCKET_H 6 #define _DATAGRAM_SOCKET_H 7 8 9 #include <AbstractSocket.h> 10 11 12 class BDatagramSocket : public BAbstractSocket { 13 public: 14 BDatagramSocket(); 15 BDatagramSocket(const BNetworkAddress& peer, 16 bigtime_t timeout = -1); 17 BDatagramSocket(const BDatagramSocket& other); 18 virtual ~BDatagramSocket(); 19 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); 24 25 virtual status_t Accept(BAbstractSocket*& _socket); 26 27 status_t SetBroadcast(bool broadcast); 28 void SetPeer(const BNetworkAddress& peer); 29 30 virtual size_t MaxTransmissionSize() const; 31 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); 36 37 // BDataIO implementation 38 39 virtual ssize_t Read(void* buffer, size_t size); 40 virtual ssize_t Write(const void* buffer, size_t size); 41 }; 42 43 44 #endif // _DATAGRAM_SOCKET_H 45