BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

open a port in Windows...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Malm32
Guest





PostPosted: Wed Feb 08, 2006 3:00 pm    Post subject: open a port in Windows... Reply with quote



Is there any way to open a port in windows or find out which ports are
open. I want to know that so as to use my program as a server. I believe
that many programs like "windows messender" or skype take advantage of
this action.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Feb 08, 2006 8:05 pm    Post subject: Re: open a port in Windows... Reply with quote



"Malm32" <antreas7 (AT) bluebottle (DOT) com> wrote in message
news:43e9f382$1 (AT) newsgroups (DOT) borland.com...

Quote:
Is there any way to open a port in windows

I assume that you are referring to a socket port? If so, then simply create
a new socket via the socket() function, bind it to a local IP/port via the
bind() function, listen on it via the listen() function, and read from via
the recv() function. Refer to the Win32 API documentation for more details.

Quote:
or find out which ports are open.

The easiest way to do that is to loop through all possible port numbers
(1-65535) attempting to bind to each one and see which ones succeed or fail.

Alternatively, there are OS hooks available that can retreive the
information more accurately. Refer to
http://www.sysinternals.com/Utilities/TcpView.html for details.

Quote:
I want to know that so as to use my program as a server.

Just pick any port number and use it in your code. Best would be if you let
the user tell your program which port number to use dynamically. If the
socket fails when you try to open it, you can tell your user about it.


Gambit
Back to top
Malm32
Guest





PostPosted: Thu Feb 09, 2006 8:03 am    Post subject: Re: open a port in Windows... Reply with quote



what i meant was if there is something like a priviledge as
SE_SHUTDOWN_NAME that enables you to shutdown windows
but what i need is something different that will enable my program to be
able to receive information on a single port that can be opened.
i know how to check if a port is already bound but what i need is to
bypass the windows firewall prior to XPSP2 that asks the user to unblock
the program. The versions before that do not ask at all. Is there any
way to bypass it from code? Just like many other programs do it?
Apart from that i have seen that many programs detect even if there is a
upnp firewall enabled and find that specific ports that either the user
has opened manually or open some themselves!!! Do you know of any
library that enables this feature?







Remy Lebeau (TeamB) wrote:
Quote:
"Malm32" <antreas7 (AT) bluebottle (DOT) com> wrote in message
news:43e9f382$1 (AT) newsgroups (DOT) borland.com...

Is there any way to open a port in windows

I assume that you are referring to a socket port? If so, then simply create
a new socket via the socket() function, bind it to a local IP/port via the
bind() function, listen on it via the listen() function, and read from via
the recv() function. Refer to the Win32 API documentation for more details.

or find out which ports are open.

The easiest way to do that is to loop through all possible port numbers
(1-65535) attempting to bind to each one and see which ones succeed or fail.

Alternatively, there are OS hooks available that can retreive the
information more accurately. Refer to
http://www.sysinternals.com/Utilities/TcpView.html for details.

I want to know that so as to use my program as a server.

Just pick any port number and use it in your code. Best would be if you let
the user tell your program which port number to use dynamically. If the
socket fails when you try to open it, you can tell your user about it.


Gambit

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Feb 09, 2006 9:03 am    Post subject: Re: open a port in Windows... Reply with quote

"Malm32" <antreas7 (AT) bluebottle (DOT) com> wrote in message
news:43eae988$1 (AT) newsgroups (DOT) borland.com...

Quote:
what i meant was if there is something like a priviledge as
SE_SHUTDOWN_NAME that enables you to shutdown
windows but what i need is something different that will enable
my program to be able to receive information on a single port
that can be opened.

Again, what you are looking for is called a socket, and sockets is not
subject to security privileges.

Quote:
what i need is to bypass the windows firewall prior to XPSP2
that asks the user to unblock the program.

You cannot bypass the firewall. That defeats the purpose of having a
running firewall in the first place.

Quote:
The versions before that do not ask at all.

Of course not, because they do not have a built-in firewall like XP does.

Quote:
Is there any way to bypass it from code?

No.

Quote:
Just like many other programs do it?

Other programs DO NOT bypass the firewall.

Quote:
Apart from that i have seen that many programs detect even if there
is a upnp firewall enabled and find that specific ports that either the
user has opened manually or open some themselves!!!

That is a completely different issue. UPnP is designed (amongst other
things) to allow programs to interact with firewalls. They are not
bypassing the firewall at all - they are cooperating with it.

Quote:
Do you know of any library that enables this feature?

Overview of Network Address Translation (NAT) in Windows XP

http://www.microsoft.com/technet/prodtechnol/winxppro/deploy/nattrnsv.mspx

Universal Plug and Play (UPnP) Client Support

http://www.microsoft.com/technet/itsolutions/network/plan/insidenet/sohonet/upnpsup.mspx

Internet Connection Sharing and Internet Connection Firewall
http://msdn.microsoft.com/library/en-us/ics/ics/portal.asp

Windows Firewall Reference

http://msdn.microsoft.com/library/en-us/ics/ics/windows_firewall_reference.asp

UPnP APIs

http://msdn.microsoft.com/library/en-us/upnp/upnp/universal_plug_and_play_start_page.asp


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.