add ReadableConnection interface
This commit is contained in:
parent
80cd187c6f
commit
44bf4a2f9e
@ -3,13 +3,12 @@
|
|||||||
#include "commons.hpp"
|
#include "commons.hpp"
|
||||||
|
|
||||||
namespace network {
|
namespace network {
|
||||||
class TcpConnection : public Connection {
|
class TcpConnection : public ReadableConnection {
|
||||||
public:
|
public:
|
||||||
~TcpConnection() override = default;
|
~TcpConnection() override = default;
|
||||||
|
|
||||||
virtual void connect(runnable callback) = 0;
|
virtual void connect(runnable callback) = 0;
|
||||||
virtual int recv(char* buffer, size_t length) = 0;
|
|
||||||
virtual int available() = 0;
|
|
||||||
virtual void setNoDelay(bool noDelay) = 0;
|
virtual void setNoDelay(bool noDelay) = 0;
|
||||||
[[nodiscard]] virtual bool isNoDelay() const = 0;
|
[[nodiscard]] virtual bool isNoDelay() const = 0;
|
||||||
|
|
||||||
|
|||||||
@ -231,7 +231,7 @@ public:
|
|||||||
readBatch.clear();
|
readBatch.clear();
|
||||||
|
|
||||||
if (state != ConnectionState::CLOSED) {
|
if (state != ConnectionState::CLOSED) {
|
||||||
shutdown(descriptor, 2);
|
shutdown(descriptor, SHUT_RDWR);
|
||||||
closesocket(descriptor);
|
closesocket(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,12 @@ namespace network {
|
|||||||
bool isprivate = false;
|
bool isprivate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ReadableConnection : public Connection {
|
||||||
|
public:
|
||||||
|
virtual int recv(char* buffer, size_t length) = 0;
|
||||||
|
virtual int available() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
public:
|
public:
|
||||||
virtual ~Server() = default;
|
virtual ~Server() = default;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user