Hi, I can't get your code to compile so I maybe wrong.

But this line

while(buf!="quit")

did catch my eye.

1. While it's syntactically correct, if you want to compare the string contained in variable buf with string "quit", it won't work. It will compare the address of variable buf with the address of string "quit", which is always different. To compare strings, use strcmp function. Try running this piece of code:

#include <stdio.h>
#include <string.h>

int main()
{
char buf[10] = "quit";

printf("buf = %s\n", buf);
if (buf == "quit") printf("%s\n", "Using '==' : match");
if (!strcmp(buf, "quit")) printf("%s\n", "Using 'strcmp' : match");
}

So you need to change that particular line to

while (strcmp(buf, "quit"))

2. I'm assuming you're using a telnet client to connect to your "server" at port 5531. I'm not so sure about this one. But I think when you type "quit" (w/o quotes) and press Enter, the client will send the string "quit" followed with the characters CR and LF (0x0d and 0x0a) to the "server".

So you may need to concatenate "quit" with CRLF (using strcat) before comparing it with buf.

Hope this helps.

Peace always,
<jdenny>