LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2005, 09:38 AM   #1
mrsharky
LQ Newbie
 
Registered: Feb 2005
Posts: 19

Rep: Reputation: 0
Port check function call


Does their exist a function call within linux that will check to see if a port is in use (on the localhost) and return true/false (or something)? I'm setting up a program to bind to no more than 3 ports at a time (lab purpose), but I need to check to see if those ports are in use first before I assign them. Thanks

Last edited by mrsharky; 04-14-2005 at 09:42 AM.
 
Old 04-14-2005, 10:25 AM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Something like 'netstat'?
 
Old 04-14-2005, 01:42 PM   #3
Intimidator
Member
 
Registered: Mar 2005
Distribution: FC4
Posts: 83

Rep: Reputation: 15
Try filtering the output of

netstat -pantu
 
Old 04-15-2005, 11:23 AM   #4
mrsharky
LQ Newbie
 
Registered: Feb 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Hopefully this will make it a little clearer... I'm trying to write a script/program that will automatically launch kismet using unique ports (say 2510, 2515, 2520...). I would like the script to run through an array (or any other method) of ports that I give it (ie. 2510, 2515, 2520....) and determine if that port is already bound by an application (ie. kismet), if it is "in-use" move onto the next port number, if next one is not bound, lauch kismet.

when one tries to launch kismet twice (default values), it fails on the second attempt because it returns a port in use/not available message.
 
Old 04-15-2005, 11:27 AM   #5
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Well your going to have to parse the output of some command like nmap or netstat either way right?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call C function in FORTRAN program bigapple Programming 5 08-24-2005 12:30 AM
How to call another function from a function? geminigal Programming 4 04-21-2005 10:41 PM
Call to undefined function domxml_open_mem() apt Programming 2 04-01-2005 03:25 AM
No Matching Function for Call ! vipinsharma Programming 2 07-05-2004 01:58 PM
how to call function?? harpal Programming 3 04-29-2003 05:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration