From: Gin Mendi Date: 2008-11-10T11:45:31+09:00 Subject: Re: Socket Progamming - Beginner questions Adam Bender wrote: > Threads can work, but most networking code I've written uses > Kernel#select. It's an incredibly powerful, yet somewhat hard to > master, method that allows you to read and write on many sockets > (actually IO objects) at the same time. It sounds like you want two > read objects, one for the server and one for the database, and that > you want to write to the network socket (yes, can you can read and > write to the same socket - just use "puts" as well as "gets", or > whatever equivalent methods you like) in the part of the code that > handles what happens when the database socket is ready to be read. > > http://www.rubycentral.com/book/ref_m_kernel.html#Kernel.select > > HTH, > > Adam Thanks Adam! I looked for examples using select and I mostly found chat servers. I tried it out and it does look like an effective and powerful approach. I still though don't understand how to trigger a read from another socket if I want to monitor a directory or a database. I wish though I could find better examples in the internet. How would you set up a socket to monitor a directory or database or is my understanding of the matter off? I checked out EventMachine as well which looks great just that since I want to learn I want to try out making something from scratch. -- Posted via http://www.ruby-forum.com/.