1.4.10 updates
This commit is contained in:
@@ -50,8 +50,8 @@ threads::Future<bool> ServerConnection::connect(const std::string &host, uint16_
|
||||
if(this->network.file_descriptor < 0) CERR("Socket setup failed");
|
||||
if(::connect(this->network.file_descriptor, reinterpret_cast<const sockaddr *>(&this->network.address_remote), sizeof(this->network.address_remote)) < 0) CERR("connect() failed (" + to_string(errno) + " | " + strerror(errno) + ")");
|
||||
int enabled = 1, disabled = 0;
|
||||
if(setsockopt(this->network.file_descriptor, SOL_SOCKET, SO_REUSEADDR, &enabled, sizeof(enabled)) < 0) CERR("could not set reuse addr");
|
||||
if(setsockopt(this->network.file_descriptor, IPPROTO_TCP, TCP_CORK, &disabled, sizeof(disabled)) < 0) CERR("could not set no push");
|
||||
if(setsockopt(this->network.file_descriptor, SOL_SOCKET, SO_REUSEADDR, &enabled, sizeof(enabled)) < 0); // CERR("could not set reuse addr");
|
||||
if(setsockopt(this->network.file_descriptor, IPPROTO_TCP, TCP_CORK, &disabled, sizeof(disabled)) < 0); // CERR("could not set no push");
|
||||
|
||||
this->network.event_base = event_base_new();
|
||||
this->network.event_read = event_new(this->network.event_base, this->network.file_descriptor, EV_READ | EV_PERSIST, ServerConnection::handleEventRead, this);
|
||||
@@ -64,7 +64,7 @@ threads::Future<bool> ServerConnection::connect(const std::string &host, uint16_
|
||||
cout << "ev ended!" << endl;
|
||||
}};
|
||||
this->network.state = ConnectionState::CONNECTED;
|
||||
this->protocol.state = protocol::HANDSCAKE;
|
||||
this->protocol.state = protocol::HANDSCHAKE;
|
||||
this->protocol.ping_thread = thread([&]{
|
||||
while(true) {
|
||||
{
|
||||
@@ -83,7 +83,7 @@ threads::Future<bool> ServerConnection::connect(const std::string &host, uint16_
|
||||
handshakeBuffer[0] = 0xC0;
|
||||
handshakeBuffer[1] = 0xFF;
|
||||
handshakeBuffer[2] = 0xEE;
|
||||
handshakeBuffer[3] = LICENSE_PROT_VERSION;
|
||||
handshakeBuffer[3] = 2;
|
||||
handshakeBuffer[4] = 1; //Im a manager
|
||||
this->sendPacket(protocol::packet{protocol::PACKET_CLIENT_HANDSHAKE, string((const char*) handshakeBuffer, 5)}); //Initialise packet
|
||||
}).detach();
|
||||
@@ -156,8 +156,8 @@ void ServerConnection::handleEventRead(int fd, short, void* _connection) {
|
||||
auto connection = (ServerConnection*) _connection;
|
||||
|
||||
char buffer[1024];
|
||||
auto read = recv(fd, buffer, 1024, SOCK_NONBLOCK);
|
||||
if(read < 0) {
|
||||
auto read = recv(fd, buffer, 1024, MSG_DONTWAIT);
|
||||
if(read <= 0) {
|
||||
if(connection->verbose)
|
||||
cout << "Invalid read: " << strerror(errno) << endl;
|
||||
connection->local_disconnect_message = "invalid read";
|
||||
|
||||
Reference in New Issue
Block a user