First, is this the "best" way to tackle the chat problem?
no. it is unlikely that someone would want to set up a chat between two processes on the same machine, sharing stdin and stdout between them. write two separate programs; the server and the client. which can be run on different machines.
> each time i try to send something from app1 to app2.
> app2 never receives the msg... but instead app1 does! why?
i've only had a cursory look, but:
the forked child process has its own copy of the parent's descriptors.
but these descriptors reference the same underlying objects as the parent.
both the parent and child processes are using the same socket, same stdin etc.