- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Bind one port by 2 programs ( Error : Port Already...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:08 PM
06-24-2004 09:08 PM
Hi All ,
I want to bind the port which is already in use by another process.( without making the changes in the first processs source code )
Rahul.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:11 PM
06-24-2004 09:11 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Only one server process can listen on a port at the same time.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:14 PM
06-24-2004 09:14 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:16 PM
06-24-2004 09:16 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
The usual way of dealing with the problem is for an application to get a connection from the client, negotiate a new port to communicate over and fork.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:19 PM
06-24-2004 09:19 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:23 PM
06-24-2004 09:23 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Regards,
Rah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:45 PM
06-24-2004 09:45 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
use lsof to find out the process which is using that port , I do not think port numbers will be stored in a source-code , it should be in a config file ..
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 09:52 PM
06-24-2004 09:52 PM
SolutionIt was real fun :)
Server/Agent process does not free the port, in general case, cause when Server and Client negociate the port, then Server forks to an agent, and come back listening on this port... So it is not free.
Rahul,
What you need is a snifer program. The easiests (and also free) will be tcpdump and ethereal. I use them on Linux. I don't know for ethereal, but I've seen on this forum that tcpdump can be compiled on HP. Nevertheless, you can use another machine on the network to snif with this programs... They can show you traffic for specific port on specific IP, and a lot much.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 10:06 PM
06-24-2004 10:06 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Alright Fred , Guys
Since I can not bind the port which is used by the another process then I came up with another solution check the following script , but it gives me the Interface error ( we can put this in the demon (Fork ) ) and accomplish the task please give your suggestion ASAP
#!/bin/csh
set PORT = $1
if ($PORT == "") then echo -n "port> " set PORT = $< endif
set IP=`/usr/sbin/ifconfig -a | grep inet | grep -v 127.0.0.1 | \ awk '{print $2}'`
foreach STATE ( ESTABLISHED LAST_ACK CLOSING TIME_WAIT CLOSE_WAIT LISTEN IDLE ) set CNT=`netstat -an | grep $IP.$PORT | grep $STATE | wc -l` echo $STATE ":" $CNT end
Regards
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 10:37 PM
06-24-2004 10:37 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
I would like to clarify a point :
Do your want to know if there is traffic on a port, or do you want to know if someone is listening on a port ?
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2004 11:08 PM
06-24-2004 11:08 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Hear is the Situation
What I Have:
One program using the port say 20000
(For Which I donâ t have source code but I know the port number it is listening to )
What I want:
I want to send the signal to another process to do some other job as soon as some data is arrived on the port no 20000.
Now how do we do this????
Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2004 12:14 AM
06-25-2004 12:14 AM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Now what you can do is to install lsof or tcpdump, and make them monitor that port. As soon as they tell you so, you can launch your work.
You should have a look at both lsof and tcpdump, as long as they do not act the same (tcpdump monitors network traffic, lsof monitors files, but as long as sockets are files...)
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2004 03:46 AM
06-26-2004 03:46 AM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
see the other thread about LD_PRELOAD
as for tcpdump, if you are scripting, you would use tcpdump. ifyou are programming, you would use libpcap (which is used by tcpdump). keep in mind that the overhead of promiscuous mode is non-trivial so using tcpdump will consume a fair amount of CPU time - particularly when the network traffic rates are high. if the rates are rather low (rates into an interface, not just the one application/port you wish to monitor) then it may not matter.
an indirect way to go would be to parse the output of ndd /dev/tcp tcp_status and notice when the receive sequence numbers change. that means that data has arrived at TCP for the given connection, but does not necessarily mean it has been read by the application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2004 04:13 AM
06-26-2004 04:13 AM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
You check whether that port is listening or requesting clinets request by command:
# netstat -a
Use "cut" to capture the appropriate field.
see man netstat,cut
Don't know how much this will help.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2004 10:10 PM
06-27-2004 10:10 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Fred Ruffet :
Rick jones :
Kapil :
Bharat Katkar :
Ok..........
Please Check the following site http://www.tcptrace.org/
Please find and download the file tcptrace-6.6.1.tar on net it has most of the source code for
Tcpdump and tcptrace , I am trying to dig out most of it. It might be useful for all the UNIX guys. Or You may download the Tcptrace from the same site : http://www.tcptrace.org/
GOOD LUCK......... Guys
Regards
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2004 12:13 AM
06-28-2004 12:13 AM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
If you have access to the client process, and the client can be configured to connect to a different port, say 20001 instead of 20000, then you could write a server side proxy program. The proxy program would listen for any connections on port 20001 coming from the client. The proxy would would also open a connection via the loopback interface to the "real" server program on port 20000. Whenever the proxy receives data from the client it would pass it directly to the "real" server and send a signal to your other process. The proxy would also have to pass data from the "real" server back to the client.
Using this method you don't have to parse any logfiles, you don't have to worry about the overhead of promiscusous mode, and you should never miss a single byte of data that gets passed to the server.
-JL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2004 11:37 PM
06-28-2004 11:37 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Just and FYI you can get a "swinstallable" version of ethereal and tcpdump off of HP's Internet Express Media:
Its available for 11.11 11.23
http://www.software.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXIEXP1111
You could use tusc also to see what the source code is doing by setting it up to follow the listener PID. Use the -f option to follow forks.
Something like this:
tusc -aeflpT "" -o tusc.out PID_OF_APP
http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/tusc-7.5/
Hope this helps,
Todd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2004 04:37 PM
06-29-2004 04:37 PM
Re: Bind one port by 2 programs ( Error : Port Already In Use )
Thanks guys, I am trying to do all the things possible to accomplish the job
All guys have added the new different avenues to the exercise to find the
solutions for the above said problem.
Thanks and Regards
Rahul