Unix Programming - Disabling a socket.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2004 > Disabling a socket.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Disabling a socket.
Gopu Bhaskar

2004-03-19, 9:41 am

Hi,
Suppose a server 'A' is listening on port 1024. Is there a way by
which we can disable this port(Temporarily), such that no more
communications take place via this port.
Thanks in advance,
Gopu.
Barry Margolin

2004-03-19, 9:41 am

In article <8af7bb28.0403182153.7b94b250@posting.google.com>,
gopugopu@rediffmail.com (Gopu Bhaskar) wrote:

> Hi,
> Suppose a server 'A' is listening on port 1024. Is there a way by
> which we can disable this port(Temporarily), such that no more
> communications take place via this port.
> Thanks in advance,
> Gopu.


Close the listening socket. This has no effect on any of the connected
sockets that were previously accepted through it.

When you want to start listening again, create a new socket and bind it
to the port.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Fletcher Glenn

2004-03-19, 11:36 am



Barry Margolin wrote:
> In article <8af7bb28.0403182153.7b94b250@posting.google.com>,
> gopugopu@rediffmail.com (Gopu Bhaskar) wrote:
>
>
>
>
> Close the listening socket. This has no effect on any of the connected
> sockets that were previously accepted through it.
>
> When you want to start listening again, create a new socket and bind it
> to the port.
>


This will have the side-effect of making the port available for other
programs to grab it and use it. To keep the port, but effectively
disable it, just accept any incoming connections and immediately close
the new socket. If this is not a concern, then Barry's solution will
work fine.

--

Fletcher Glenn

Gopu Bhaskar

2004-03-20, 10:38 am

Barry Margolin <barmar@alum.mit.edu> wrote in message news:<barmar-828E43.01252719032004@comcast.ash.giganews.com>...
> In article <8af7bb28.0403182153.7b94b250@posting.google.com>,
> gopugopu@rediffmail.com (Gopu Bhaskar) wrote:
>
>
> Close the listening socket. This has no effect on any of the connected
> sockets that were previously accepted through it.
>
> When you want to start listening again, create a new socket and bind it
> to the port.


I was looking for a generalized solution .
ie want to 'disable' any port of any process.
Sean Burke

2004-03-20, 10:38 am


gopugopu@rediffmail.com (Gopu Bhaskar) writes:

> Barry Margolin <barmar@alum.mit.edu> wrote in message news:<barmar-828E43.01252719032004@comcast.ash.giganews.com>...
>
> I was looking for a generalized solution .
> ie want to 'disable' any port of any process.


Sounds like you want a packet filter then.
There's no generic unix way to do this.
You would need to look at what facilities
are available for your specific OS.

-SEan
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com