This is not a web-server. It's just socket communication. Your program probably does not work because there is no linefeed in the "Hello server!". Even though you flushed, your server-side read is looking for the linefeed.
If your communication is across systems, look at inetd/xinetd. There is plenty of documentation on them, and they are very easy to use.