10e478f5aSAxel Dörfler /* 20e478f5aSAxel Dörfler * Copyright 2011, Haiku, Inc. All Rights Reserved. 30e478f5aSAxel Dörfler * Distributed under the terms of the MIT License. 40e478f5aSAxel Dörfler */ 50e478f5aSAxel Dörfler #ifndef _DATAGRAM_SOCKET_H 60e478f5aSAxel Dörfler #define _DATAGRAM_SOCKET_H 70e478f5aSAxel Dörfler 80e478f5aSAxel Dörfler 90e478f5aSAxel Dörfler #include <AbstractSocket.h> 100e478f5aSAxel Dörfler 110e478f5aSAxel Dörfler 120e478f5aSAxel Dörfler class BDatagramSocket : public BAbstractSocket { 130e478f5aSAxel Dörfler public: 140e478f5aSAxel Dörfler BDatagramSocket(); 150e478f5aSAxel Dörfler BDatagramSocket(const BNetworkAddress& peer, 160e478f5aSAxel Dörfler bigtime_t timeout = -1); 170e478f5aSAxel Dörfler BDatagramSocket(const BDatagramSocket& other); 180e478f5aSAxel Dörfler virtual ~BDatagramSocket(); 190e478f5aSAxel Dörfler 20*c9dd7d0dSRene Gollent virtual status_t Bind(const BNetworkAddress& peer, 21*c9dd7d0dSRene Gollent bool reuseAddr = true); 220e478f5aSAxel Dörfler virtual status_t Connect(const BNetworkAddress& peer, 230e478f5aSAxel Dörfler bigtime_t timeout = B_INFINITE_TIMEOUT); 240e478f5aSAxel Dörfler 25*c9dd7d0dSRene Gollent virtual status_t Accept(BAbstractSocket*& _socket); 26*c9dd7d0dSRene Gollent 270e478f5aSAxel Dörfler status_t SetBroadcast(bool broadcast); 280e478f5aSAxel Dörfler void SetPeer(const BNetworkAddress& peer); 290e478f5aSAxel Dörfler 300e478f5aSAxel Dörfler virtual size_t MaxTransmissionSize() const; 310e478f5aSAxel Dörfler 3249e7165fSAdrien Destugues virtual ssize_t SendTo(const BNetworkAddress& address, 330e478f5aSAxel Dörfler const void* buffer, size_t size); 3449e7165fSAdrien Destugues virtual ssize_t ReceiveFrom(void* buffer, size_t bufferSize, 350e478f5aSAxel Dörfler BNetworkAddress& from); 360e478f5aSAxel Dörfler 370e478f5aSAxel Dörfler // BDataIO implementation 380e478f5aSAxel Dörfler 390e478f5aSAxel Dörfler virtual ssize_t Read(void* buffer, size_t size); 400e478f5aSAxel Dörfler virtual ssize_t Write(const void* buffer, size_t size); 410e478f5aSAxel Dörfler }; 420e478f5aSAxel Dörfler 430e478f5aSAxel Dörfler 440e478f5aSAxel Dörfler #endif // _DATAGRAM_SOCKET_H 45