title: Issue with recv socket type argument
body: <p>Hello I need to receive messages from the socket as string, I am having issues with the recv() it requires a void* but i need it in string i am fairly new to c++ any help would be greatly appreciated. the code I am using is listed below.</p>
  
  <pre><code>#include "server.h"
  
  using namespace std;
  
  //Actually allocate clients
  vector&lt;Client&gt; Server::chatClients;
  
  Server::Server() {
  
      //Initialize the  mutex
      Thread::initMut();
      int yes = 1;
      //https://www.cs.cmu.edu/afs/cs/academic/class/15213-f99/www/class26/tcpserver.c
      serverSocket = socket(AF_INET, SOCK_STREAM, 0);
      memset(&amp;serverAddr, 0, sizeof(sockaddr_in));
      serverAddr.sin_family = AF_INET;
      serverAddr.sin_addr.s_addr = INADDR_ANY;
      serverAddr.sin_port = htons(PORT);
  
      //check if socket was closed last time;
      setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &amp;yes, sizeof(int));
  
      if(::bind(serverSocket, (struct sockaddr *) &amp;serverAddr, sizeof(sockaddr_in)) &lt; 0)
          cerr &lt;&lt; "Failed during the binding process";
          listen(serverSocket, 5);
  }
  
  void Server::receiveAndSend() {
  
      Client *client;
      Thread *thread;
  
      socklen_t cliSize = sizeof(sockaddr_in);
      //run forever
      while(true) {
  
          client = new Client();
          thread = new Thread();
  
          client-&gt;socket = accept(serverSocket, (struct sockaddr *) &amp;clientAddr, &amp;cliSize);
  
          if(client-&gt;socket &lt; 0) {
              cerr &lt;&lt; "Error while accepting";
          }
          else {
              thread-&gt;generate((void *) Server::ClientHandler, client);
          }
      }
  }
  
  //todo use one lock, and change everything to a string.
  
  void *Server::ClientHandler(void *args) {
  
      //client Pointer
      Client *client = (Client *) args;
      string buffer;
      string message;
      int index;
      int n;
  
      //Add client to the clients vector
      Thread::lockMut((const string) client-&gt;clientName);
  
      //set the id of the client by getting the largest index of the vector
      client-&gt;setClientId(Server::chatClients.size());
      client-&gt;setClientName(buffer);
      cout &lt;&lt; "Adding client with id: " &lt;&lt; client-&gt;clientId &lt;&lt; endl;
      Server::chatClients.push_back(*client);
  
      Thread::unlockMut((const string) client-&gt;clientName);
  
      while(1) {
  //        memset(buffer, 0, sizeof buffer);
          n = recv(client-&gt;socket, buffer.c_str(), sizeof buffer, 0);
  
          //Client disconnected?
          if(n == 0) {
              cout &lt;&lt; "Client " &lt;&lt; client-&gt;clientName &lt;&lt; " diconnected" &lt;&lt; endl;
              close(client-&gt;socket);
  
              //Remove client in Static clients &lt;vector&gt; (Critical section!)
              Thread::lockMut((const char *) client-&gt;clientName);
  
              index = Server::getClientIndex(client);
              cout &lt;&lt; "earse user with index:  " &lt;&lt; index &lt;&lt; "andid is: "
                   &lt;&lt; Server::chatClients[index].clientId &lt;&lt; endl;
              Server::chatClients.erase(Server::chatClients.begin() + index);
  
              Thread::unlockMut((const char * ) client-&gt;clientName);
  
              break;
          }
          else if(n &lt; 0) {
              cerr &lt;&lt; "receive error: " &lt;&lt; client-&gt;clientName &lt;&lt; endl;
          }
          else {
              //Message is here now broadcast.
              cout &lt;&lt; message.c_str() &lt;&lt; " " &lt;&lt; client-&gt;clientName  &lt;&lt; "  "  &lt;&lt; buffer;
              cout &lt;&lt; "Will send to all: " &lt;&lt; message &lt;&lt; endl;
              Server::PublicBroadcast(message);
          }
      }
  
      //End thread
      return NULL;
  }
  
  void Server::PublicBroadcast(string message) {
      int size;
  
      //Acquire the lock
      Thread::lockMut("'PublicBroadcast()'");
  
      for(size_t i=0; i&lt;chatClients.size(); i++) {
  
  //       ssize_t    send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send);
          cout &lt;&lt; message &lt;&lt; endl ;
          size = send(Server::chatClients[i].socket, message.c_str(), message.length(),0);
          cout &lt;&lt; size &lt;&lt; " sent bytes." &lt;&lt; endl;
      }
  
      //Release the lock
      Thread::unlockMut("'PublicBroadcast()'");
  }
  
  void Server::ListClients() {
      for(size_t i=0; i&lt;chatClients.size(); i++) {
          cout &lt;&lt; chatClients.at(i).clientName &lt;&lt; endl;
      }
  }
  
  /*
    Should be called when vector&lt;Client&gt; clients is locked!
  */
  
  int Server::getClientIndex(Client *client) {
      for(size_t i=0; i&lt;chatClients.size(); i++) {
          if((Server::chatClients[i].clientId) == client-&gt;clientId) return (int) i;
      }
      cerr &lt;&lt; "clientId not found." &lt;&lt; endl;
      return -1;
  }
  </code></pre>