Seth Arnold <sarnold@wirex.com> writes: > On Tue, May 06, 2003 at 11:52:55AM +0530, Sriram Neelakanta Subramoney wrote: >> How to dynamically get a free TCP/UDP port that can be used at the >> client's end when connecting to a server[@ a pre-defined destination >> port] over socket. Is there any call available for this??. > > You should probably be re-examining your design if you want to initiate > tcp/ip sessions from within the kernel. This is a horrible design -- you > should be writing these applications using the system call interface. > (That is why the system calls exist!) Say you were writing a new virtual filesystem that was transparently distributed over multiple hosts -- like NFS but distributed (and encrypted, these days). If you did it in the kernel, as NFS is often implemented, wouldn't you be doing just that -- initiating UDP or TCP connections from inside the kernel? If you didn't do it in the kernel would you have a daemon in userland for handling the vfs backend duties? It could sleep until there's work to do, at which point the kernel would copy data into the daemon's buffers and wake it up. Then the daemon would do the distributed fs backend stuff in userland. I'm just guessing you could do it that way, but I'd be interested to hear whether that's really how it's done. -- --Ed L Cashin PGP public key: http://noserose.net/e/pgp/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/