10e478f5aSAxel Dörfler /* 2*c9dd7d0dSRene Gollent * Copyright 2011-2016, Haiku, Inc. All Rights Reserved. 30e478f5aSAxel Dörfler * Distributed under the terms of the MIT License. 40e478f5aSAxel Dörfler */ 50e478f5aSAxel Dörfler #ifndef _SOCKET_H 60e478f5aSAxel Dörfler #define _SOCKET_H 70e478f5aSAxel Dörfler 80e478f5aSAxel Dörfler 90e478f5aSAxel Dörfler #include <AbstractSocket.h> 100e478f5aSAxel Dörfler 110e478f5aSAxel Dörfler 120e478f5aSAxel Dörfler class BSocket : public BAbstractSocket { 130e478f5aSAxel Dörfler public: 140e478f5aSAxel Dörfler BSocket(); 150e478f5aSAxel Dörfler BSocket(const BNetworkAddress& peer, 160e478f5aSAxel Dörfler bigtime_t timeout = B_INFINITE_TIMEOUT); 170e478f5aSAxel Dörfler BSocket(const BSocket& other); 180e478f5aSAxel Dörfler virtual ~BSocket(); 190e478f5aSAxel Dörfler 20*c9dd7d0dSRene Gollent virtual status_t Bind(const BNetworkAddress& peer, 21*c9dd7d0dSRene Gollent bool reuseAddr = true); 22*c9dd7d0dSRene Gollent 23*c9dd7d0dSRene Gollent virtual status_t Accept(BAbstractSocket*& _socket); 24*c9dd7d0dSRene Gollent 250e478f5aSAxel Dörfler virtual status_t Connect(const BNetworkAddress& peer, 260e478f5aSAxel Dörfler bigtime_t timeout = B_INFINITE_TIMEOUT); 270e478f5aSAxel Dörfler 280e478f5aSAxel Dörfler // BDataIO implementation 290e478f5aSAxel Dörfler 300e478f5aSAxel Dörfler virtual ssize_t Read(void* buffer, size_t size); 310e478f5aSAxel Dörfler virtual ssize_t Write(const void* buffer, size_t size); 320e478f5aSAxel Dörfler 33*c9dd7d0dSRene Gollent protected: 340e478f5aSAxel Dörfler 350e478f5aSAxel Dörfler void _SetTo(int fd, const BNetworkAddress& local, 360e478f5aSAxel Dörfler const BNetworkAddress& peer); 370e478f5aSAxel Dörfler }; 380e478f5aSAxel Dörfler 390e478f5aSAxel Dörfler 400e478f5aSAxel Dörfler #endif // _SOCKET_H 41