libbnetapi: Extend socket classes.
B{Abstract,Datagram,Secure}Socket:
- Add functionality to listen for and accept new connections, thus allowing
one to use the socket classes for server functionality as well.
BSecureSocket:
- Adjust to take into account differences between how SSL needs to be called
when accepting an incoming connection vs initiating an outbound one.
The handshake on the accepted connection stills fails for unknown reasons
at the moment though.
Note that these changes break the ABI, and thus any packages making use of
them directly will need a rebuild.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2011-2016, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ABSTRACT_SOCKET_H
|
||||
@@ -20,8 +20,12 @@ public:
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
virtual status_t Bind(const BNetworkAddress& local) = 0;
|
||||
virtual status_t Bind(const BNetworkAddress& local, bool reuseAddr) = 0;
|
||||
virtual bool IsBound() const;
|
||||
virtual bool IsListening() const;
|
||||
|
||||
virtual status_t Listen(int backlog = 10);
|
||||
virtual status_t Accept(BAbstractSocket*& _socket) = 0;
|
||||
|
||||
virtual status_t Connect(const BNetworkAddress& peer,
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT) = 0;
|
||||
@@ -44,9 +48,12 @@ public:
|
||||
int Socket() const;
|
||||
|
||||
protected:
|
||||
status_t Bind(const BNetworkAddress& local, int type);
|
||||
status_t Bind(const BNetworkAddress& local,
|
||||
bool reuseAddr, int type);
|
||||
status_t Connect(const BNetworkAddress& peer, int type,
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
status_t AcceptNext(int& _acceptedSocket,
|
||||
BNetworkAddress& _peer);
|
||||
|
||||
private:
|
||||
status_t _OpenIfNeeded(int family, int type);
|
||||
@@ -60,6 +67,7 @@ protected:
|
||||
BNetworkAddress fPeer;
|
||||
bool fIsBound;
|
||||
bool fIsConnected;
|
||||
bool fIsListening;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user