It looks like your program is missing something vital: a loop. Or two. Maybe more. And a call to select, or perhaps some lovely threads.

AFAICT, you code check to see if it has a remote connection, then blithely continues on whether it does or not, then sends some data to this hypothetical connection, then closes it all up and goes away. Not sure, I don't have an API reference handy.

Basically, I think you're being a bit overambitious. Try writing a client that accepts input and writes it to a file, first. Then perhaps try writing another program that reads from that file as it's being written. Then merge the two programs together. After that, try writing your char program again.

And any way, with the structure you're using, you'll only be able to support two users.