I'm trying to write an application in C++ that has two things - a TCP server (listen server) as well as a TCP client where it can send to other TCP servers. I currently have both parts set up simultaneously. I did this by calling fork() and having the listen server begin to listen in the child process and having the parent process prompt the user for input. however, this is where the program hangs. Because I am prompting the user for input via 'cin', its blocking the TCP listen server from receiving any messages.
So, I have a few questions. One, since I called fork(), why would cin block the TCP server? Arent they, in essence, two different programs? Also, is there a way do do a non-blocking 'cin' ? Do you have any other suggestions for other ways to successfully implement this?