RE: How to get a free TCP/UDP port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My application has to run in the user-space and is expected to send UDP
messages to the remote entity over sockets. In this regard, port numbers
are to be used [from the free-pool of UDP/TCP ports, 
i.e., >= 1024] to be used as source-port while the destination port will
be a pre-defined number.
I wish to know if any such call exists that can fetch me one port from
the free pool for every call, i.e., something which wont clash with that
used by some other process at the same time.

Rgds,
Sriram

-----Original Message-----
From: Seth Arnold [mailto:sarnold@wirex.com] 
Sent: Tuesday, May 06, 2003 12:20 PM
To: kernelnewbies@nl.linux.org
Subject: Re: How to get a free TCP/UDP port


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!)

In userspace, you would use connect() for this task -- and so, if you're
intent on making your sessions from within the kernel, start by looking
for sys_connect(). When you find it, figure out what isn't needed
because your call is coming from kernelspace, not userspace, and
re-implement the important bits that you can't just call.

Best of luck.


-- 
"The Constitution of the United States is the law for rulers and people,
equally in war and peace, and covers with the shield of its protection
all
classes of men, at all times, and under all circumstances." -- David
Davis
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux