2 * Copyright 2011-2016, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _ABSTRACT_SOCKET_H
6 #define _ABSTRACT_SOCKET_H
10 #include <NetworkAddress.h>
12 #include <sys/socket.h>
15 class BAbstractSocket
: public BDataIO
{
18 BAbstractSocket(const BAbstractSocket
& other
);
19 virtual ~BAbstractSocket();
21 status_t
InitCheck() const;
23 virtual status_t
Bind(const BNetworkAddress
& local
, bool reuseAddr
) = 0;
24 virtual bool IsBound() const;
25 virtual bool IsListening() const;
27 virtual status_t
Listen(int backlog
= 10);
28 virtual status_t
Accept(BAbstractSocket
*& _socket
) = 0;
30 virtual status_t
Connect(const BNetworkAddress
& peer
,
31 bigtime_t timeout
= B_INFINITE_TIMEOUT
) = 0;
32 virtual bool IsConnected() const;
33 virtual void Disconnect();
35 virtual status_t
SetTimeout(bigtime_t timeout
);
36 virtual bigtime_t
Timeout() const;
38 virtual const BNetworkAddress
& Local() const;
39 virtual const BNetworkAddress
& Peer() const;
41 virtual size_t MaxTransmissionSize() const;
43 virtual status_t
WaitForReadable(bigtime_t timeout
44 = B_INFINITE_TIMEOUT
) const;
45 virtual status_t
WaitForWritable(bigtime_t timeout
46 = B_INFINITE_TIMEOUT
) const;
51 status_t
Bind(const BNetworkAddress
& local
,
52 bool reuseAddr
, int type
);
53 status_t
Connect(const BNetworkAddress
& peer
, int type
,
54 bigtime_t timeout
= B_INFINITE_TIMEOUT
);
55 status_t
AcceptNext(int& _acceptedSocket
,
56 BNetworkAddress
& _peer
);
59 status_t
_OpenIfNeeded(int family
, int type
);
60 status_t
_UpdateLocalAddress();
61 status_t
_WaitFor(int flags
, bigtime_t timeout
) const;
66 BNetworkAddress fLocal
;
67 BNetworkAddress fPeer
;
74 #endif // _ABSTRACT_SOCKET_H