Basic multithread server code I wrote a simple multithread server to use as a base class for other different types of multithread servers. I haven't had a lot of opportunities to get code critique from other people, so I wanted to post here to see how much coding style was. Any constructive feedback on how to improve my code would be appreciated! I'm personally looking more for code style and quality rather than compilability (since it does compile and work)

define.h

#pragma once

#define DEBUG
#ifndef DEBUG
#define _(x) 
#else
#define _(x) x
#endif


Server.h

#pragma once

#include &lt;iostream&gt;
#include &lt;netinet/in.h&gt;
#include &lt;unistd.h&gt;
#include &lt;string.h&gt;
#include &lt;thread&gt;
#include &lt;map&gt;
#include "define.h"

class Server{
    private:
        virtual void handle_connection(int sockfd);
    public:
        Server() {}
        void initialize(int port);
        void start_listening(int socket);
        void authenticate(int sockfd);
        void sendMessage(int sockfd, std::string prompt);
        ~Server() {}
};


Server.cpp

#include "server.h"

void Server::initialize(int port){
    int sockfd;
    struct sockaddr_in serv_addr;

    //Create socket
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if(sockfd &lt; 0){
        perror("Error: Failed to initialize socket.\n");
        exit(1);
    }

    //Bind socket
    bzero((char *) &amp;serv_addr, sizeof(serv_addr));
    serv_addr.sin_family        = AF_INET;
    serv_addr.sin_port      = htons(port);
    serv_addr.sin_addr.s_addr   = INADDR_ANY;
    if(bind(sockfd, (struct sockaddr *) &amp;serv_addr, sizeof(serv_addr)) &lt; 0){
        perror("Error: Failed to bind socket to address.\n");
        exit(1);
    }

    start_listening(sockfd);
    return;
}

void Server::start_listening(int socket){
    while(1){
        int newsockfd = -1;
        struct sockaddr_in cli_addr;
        socklen_t clilen = sizeof(cli_addr);

        listen(socket, 5);
        newsockfd = accept(socket, (struct sockaddr *) &amp;cli_addr, &amp;clilen);

        if(newsockfd &lt; 0){
            perror("Error: Failed to connect to incoming connection.\n");
        }

        //Start new thread to handle request
        std::thread t1 (&amp;Server::handle_connection, this, newsockfd);
        t1.detach();
    }
}

void Server::handle_connection(int sockfd){
    char buffer[256];
    std::string response = "Thank you for your response.\n";
    const char* responseChar = response.c_str();
    authenticate(sockfd);
    while(recv(sockfd, buffer, 255, 0) &gt; 0){
        std::cout &lt;&lt; buffer;
        send(sockfd, (void*)responseChar, strlen(responseChar), MSG_NOSIGNAL);
        bzero(buffer, 256);
    }
    close(sockfd);
    return;
}

void Server::sendMessage(int sockfd, std::string prompt){
    const char * promptChar = prompt.c_str();
    send(sockfd, (void*)promptChar, strlen(promptChar), MSG_NOSIGNAL);
}
Include (only) what you use
Users of Server.h don't need most of those headers; they can be reduced to
#include &lt;string&gt;

You might need some of the other headers in the implementation, but try to avoid polluting users' namespaces (and slowing their compilations).
Consider adding daemonize code
Most servers want to be able to daemonize before they start - provide a facility to do the forking and dissociation of controlling terminal and the rest.  Make sure it's optional, so users can run in foreground if they want (e.g. for debugging, or when controlled by a supervisor like systemd).
Report errors back to caller
Consider this code:
    if(newsockfd &lt; 0){
        perror(&quot;Error: Failed to connect to incoming connection.\n&quot;);
    }

This prints a message to stderr, and then keeps going.  How does the server (subclass) know that we failed?  What if we want to syslog the failure?  It's better to communicate this information in return value or an exception, so the application can take the right action - here, in a library, we don't know what's appropriate, nor whether standard error stream is even available to us.