Re: Checking Ports? (fwd)
On Mon, Jun 08, 1998 at 01:54:40PM +0100, David Wright wrote: > I run a very simple joystick server that writes its position to a port, say, > 50005, so that (a) multiple clients can connect to the stick (b) I can run > a fake server on machines without a stick and continue to test programs that > need to read a stick. > > When I kill the server, I find I often can't restart it on that port, but > can on, say, 50006. I'm guessing that some resource stays around until it's > killed off, usually after less than a minute. > > I intend making my server pick the next free port, and likewise the clients > will have to play chase the server. Meanwhile I don't worry. You need to set the socket to be reusable, eg: int fd, on = 1; [...] /* Set it to be re-usable */ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0) { fprintf(stderr, "Could not set socket options\n"); } Hamish -- Hamish Moffatt, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Latest Debian packages at ftp://ftp.rising.com.au/pub/hamish. PGP#EFA6B9D5 CCs of replies from mailing lists are welcome. http://hamish.home.ml.org -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Checking Ports? (fwd)
On Fri, 5 Jun 1998, Marcus Johnson wrote: > -- Forwarded message -- > Date: Fri, 5 Jun 1998 12:50:21 -0700 (PDT) > From: Marcus Johnson <[EMAIL PROTECTED]> > To: John Hasler <[EMAIL PROTECTED]> > Subject: Re: Checking Ports? > > Sorry for my brevity and thank you for your answer. I meant ports as in > IP ports. I tried to start a server-type program but it exits and tells > me that port is already in use. This seems very odd to me because I > should be the only one using it. I suspect its still running another copy > of my server. How can I find out and if it is another instance of my > server how can I kill it? I run a very simple joystick server that writes its position to a port, say, 50005, so that (a) multiple clients can connect to the stick (b) I can run a fake server on machines without a stick and continue to test programs that need to read a stick. When I kill the server, I find I often can't restart it on that port, but can on, say, 50006. I'm guessing that some resource stays around until it's killed off, usually after less than a minute. I intend making my server pick the next free port, and likewise the clients will have to play chase the server. Meanwhile I don't worry. Cheers, -- Email: [EMAIL PROTECTED] Tel: +44 1908 653 739 Fax: +44 1908 655 151 Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA Disclaimer: These addresses are only for reaching me, and do not signify official stationery. Views expressed here are either my own or plagiarised. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Checking Ports? (fwd)
-- Forwarded message -- Date: Fri, 5 Jun 1998 12:50:21 -0700 (PDT) From: Marcus Johnson <[EMAIL PROTECTED]> To: John Hasler <[EMAIL PROTECTED]> Subject: Re: Checking Ports? Sorry for my brevity and thank you for your answer. I meant ports as in IP ports. I tried to start a server-type program but it exits and tells me that port is already in use. This seems very odd to me because I should be the only one using it. I suspect its still running another copy of my server. How can I find out and if it is another instance of my server how can I kill it? Marcus On Fri, 5 Jun 1998, John Hasler wrote: > > Is there a way for a nonSysAdmin to check to see what program is using a > > particular port? Even if the program is being run by a different user? > > Do you mean serial ports? > > lsof | grep "/dev/ttyS1" | cut -f1 -d' ' > > will produce a list of all programs with /dev/ttyS1 open. > > John Hasler <[EMAIL PROTECTED]> > -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]