I\'m working on a dictionary server via telnet, and I\'d like it to return it in this format:
**word** (wordType): wordDef wordDef wordDef wordDef
wordDef w
Consider using using something like VT100 escape sequences. Since your server is telnet based the user is likely to have a client that supports various terminal modes.
For instance if you wanted to turn on bold for a VT100 terminal you would output
ESC[1m
where "ESC" is the character value 0x1b. To switch back to normal formatting output
ESC[0m
To use this in your application you can change the example lines from your question to the following.
std::string str = "Hello!"
write( my_socket, "\x1b[1m", 4); // Turn on bold formatting
write( my_socket, str.c_str(), str.size()); // output string
write( my_socket, "\x1b[0m", 4); // Turn all formatting off
There other terminal modes such as VT52, VT220, etc. You might want to look into using ncurses although it might be a bit heavy if all you need is simple bold on/off.