![]() |
Home
| Calendar
| Mail Lists
| List Archives
| Desktop SIG
| Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU |
On Sunday 10 April 2005 3:28 pm, Anand Rao wrote: > hi , > I have a text based interactive application that I need to run on a > port. > > I had read some articles regarding the usage of xinet or inetd for > this purpose .. any Good pointers or suggestions to start on this ? There are a few ways you can do this. One way is to have the application listening on the port. Depending on its design, it could listen, then spawn a child (process or thread). The ssh, http and smtp(mail) daemons are usually set up this way. Other comm applications are initiated by xinetd (or inetd) where xinetd listens on multiple ports, and initiates the appropriate daemon. For the first pass, I would take the first approach. Internally, the application would: 1. open a socket using socket(2) system call. 2. bind(2) to that port. 3. listen(2) on that port. When an application tries to connect to that port, listen(2) returns 0 on success. 4. Upon successful return, use the accept(2) function to accept the connection. Accept returns a non-negative integer on success that becomes the file descriptor for subsequent read/write operations. At this point you can fork a child process (or thread), while the main process (thread) goes back and listens. Remember in Unix and Linux, open files are passed to child processes, so the listener process could be just a stub. -- Jerry Feldman <gerald.feldman at hp.com> Partner Technology Access Center (contractor) (PTAC-MA) Hewlett-Packard Co. 550 King Street LKG2a-X2 Littleton, Ma. 01460 (978)506-5243
![]() |
|
BLU is a member of BostonUserGroups | |
We also thank MIT for the use of their facilities. |