in reply to Non-forked, bi-directional client/server

POE is indeed shiney good value. But to answer your other questions, you don't need two ports, you can just read and write to the same socket. The data won't get mixed up.

As regards shifting information around, it is traditional to do "callbacks" - calling a subroutine to process data that you read, calling a subroutine to prepare some data, and then sending the prepared data. Things like event queues and packet queues are sometimes useful.

The big reason not to do this is that while you are doing anything, you aren't waiting for the next connection, or the next packet of data. This will probably only show up under load i.e. when you use it for real for the first time.

This is the way it tends to go:

while (1) { $new_conn = do_select(); add_connection( $new_conn ) if $new_conn; read_all_connections(); process_data(); write_all_connections(); }

but it gets very messy since you have to maintain state information for each socket, etc. Which is why a object interface like POE is a great idea.

____________________
Jeremy
I didn't believe in evil until I dated it.