Mark has the following rather unorthodox application protocol: His application is a client to two different servers. He makes a connection Server A and receives some data from it. Then while the connection to Server is still running, he connects to Server B. He sends to Server B a request (that somehow reflects the data received from A). He takes the reply from B, closes the connection to B, and then sends the data received from Server B back to Server A. Somewhat unusual, but here''s how you can do it in EventMachine. Now notice, we''re *not* meeting Mark''s ideal goal of wrapping up the interaction with server B as a function call. (To do that would require another thread.) As I said, this is unorthodox, but it works. require ''rubygems'' require ''eventmachine'' module ServerA def receive_data data server_b = EventMachine.connect "192.168.xx.yy", 8101, ServerB server_b.send_data data server_b.reply_to(self) end end module ServerB def reply_to server_a @reply_to = server_a end def receive_data data @reply_to.send_data data end end EventMachine.run { EventMachine.connect "192.168.xx.yy", 8100, ServerA } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20060524/d10411aa/attachment.htm