title: single char from socket, one at a time
body: <p>I'm working on a small telnetish game in C with text based gui.
  I need to get a single char from a socket without '\n' needed so i can get control over keys.</p>
  
  <p>I have something like </p>
  
  <pre><code>16     char buffer[256];
  17     bzero(buffer,256);
  18     n = read(sock,buffer,255);
  </code></pre>
  
  <p>but <code>read()</code> accepts only <code>char *</code>.</p>
  
  <p><code>recv()</code> is better but you still need to pass '\n' to get it.</p>
  
  <p>I found a way to turn off telnet line mode, but that's not working for me, and/or I don't understand it.</p>
  
  <pre><code>write(s,"\377\375\042\377\373\001",6);
  </code></pre>
  
  <p>From what I have found on a forum there might be a way to do it with ncurses.</p>
  
  <p>What is the best way to do it? </p>
  
  <p>what I'm at</p>
  
  <pre><code> 12 void doprocessing (int sock)
   13 {   
   14     int n;
   15     int i;
   16     char buffer;
   17     n = recv(sock,&amp;buffer,1,0);
   18     if (n &lt; 0)
   19     {   
   20         perror("ERROR reading from socket");
   21         exit(1);
   22     }
   23     printf("MSG: %c\n",buffer);
   24     n = write(sock,"MSG SENT\n",18);
   25 }
  </code></pre>