1/*
2 * Copyright 2011-2016, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _SOCKET_H
6#define _SOCKET_H
7
8
9#include <AbstractSocket.h>
10
11
12class BSocket : public BAbstractSocket {
13public:
14								BSocket();
15								BSocket(const BNetworkAddress& peer,
16									bigtime_t timeout = B_INFINITE_TIMEOUT);
17								BSocket(const BSocket& other);
18	virtual						~BSocket();
19
20	virtual	status_t			Bind(const BNetworkAddress& peer,
21									bool reuseAddr = true);
22
23	virtual	status_t			Accept(BAbstractSocket*& _socket);
24
25	virtual	status_t			Connect(const BNetworkAddress& peer,
26									bigtime_t timeout = B_INFINITE_TIMEOUT);
27
28	// BDataIO implementation
29
30	virtual ssize_t				Read(void* buffer, size_t size);
31	virtual ssize_t				Write(const void* buffer, size_t size);
32
33protected:
34
35			void				_SetTo(int fd, const BNetworkAddress& local,
36									const BNetworkAddress& peer);
37};
38
39
40#endif	// _SOCKET_H
41