473,786 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the remote port number in asp.net

I know that I can get the SERVER port number like this:

HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]

My question is how do I get the remote CLIENT port number?

Thanks
Derek

Oct 18 '06 #1
9 13575
For communication to work, the client and server would have to use the same
port. So, it's safe to say the the client port and the server port should be
the same. However, this may not be the case. I'm sure someone would correct
me if I am wrong.

<xp******@gmail .comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
>I know that I can get the SERVER port number like this:

HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]

My question is how do I get the remote CLIENT port number?

Thanks
Derek
Oct 18 '06 #2

HttpContext.Cur rent.Request.Us erHostAddress
or Request.UserHos tAddress if you're working inline code.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
<xp******@gmail .comwrote in message news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
>I know that I can get the SERVER port number like this:

HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]

My question is how do I get the remote CLIENT port number?

Thanks
Derek

Oct 18 '06 #3
Please ignore that reply.

I thought you were asking for the user's IP address, not the port.

re:
My question is how do I get the remote CLIENT port number?
There's no such animal.
The client will make the request on whatever port the server is configured for.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:OL******** ******@TK2MSFTN GP05.phx.gbl...
>
HttpContext.Cur rent.Request.Us erHostAddress
or Request.UserHos tAddress if you're working inline code.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
<xp******@gmail .comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
>>I know that I can get the SERVER port number like this:

HttpContext.Cu rrent.Request.S erverVariables["SERVER_POR T"]

My question is how do I get the remote CLIENT port number?

Thanks
Derek


Oct 18 '06 #4
<xp******@gmail .comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
>I know that I can get the SERVER port number like this:

HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]

My question is how do I get the remote CLIENT port number?
I'm not sure which port you're referring to here...???
Oct 18 '06 #5
I'm referring to the client TCP/IP port number that the http response
will be sent on. If I go onto the web server and use a utility like
netstat I can see both sides of the connection -- usually, the server
port number will be 80 or 443 and the client will be a high port
number. I'm wondering if there is a way to access this port number via
code.

On Oct 18, 10:37 am, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
<xparr...@gmail .comwrote in messagenews:11* *************** ******@b28g2000 cwb.googlegroup s.com...
I know that I can get the SERVER port number like this:
HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]
My question is how do I get the remote CLIENT port number?I'm not sure which port you're referring to here...???
Oct 18 '06 #6
I think that high port number you may be seeing is a result of NAT that is
usually done by routers. You will not be able to get this port number since
this is not seen from the outside world. So, in the end, the client and
server will communicate using the same port (80 or 443); but NAT makes it
seem like its using another port.

<xp******@gmail .comwrote in message
news:11******** ************@i3 g2000cwc.google groups.com...
I'm referring to the client TCP/IP port number that the http response
will be sent on. If I go onto the web server and use a utility like
netstat I can see both sides of the connection -- usually, the server
port number will be 80 or 443 and the client will be a high port
number. I'm wondering if there is a way to access this port number via
code.

On Oct 18, 10:37 am, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
><xparr...@gmai l.comwrote in
messagenews:11 *************** *******@b28g200 0cwb.googlegrou ps.com...
>I know that I can get the SERVER port number like this:
HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]
My question is how do I get the remote CLIENT port number?I'm not sure
which port you're referring to here...???
Oct 18 '06 #7
re:
I'm referring to the client TCP/IP port number that the http response will be sent on.
I'm wondering if there is a way to access this port number via code.
I think that's a random number above 1024.
It's picked from the pool of available ports (so as to avoid picking one that currently in use).

There's absolutely no programming need which could be
filled by accessing it before the packets are actually sent.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
<xp******@gmail .comwrote in message news:11******** ************@i3 g2000cwc.google groups.com...
I'm referring to the client TCP/IP port number that the http response
will be sent on. If I go onto the web server and use a utility like
netstat I can see both sides of the connection -- usually, the server
port number will be 80 or 443 and the client will be a high port
number. I'm wondering if there is a way to access this port number via
code.

On Oct 18, 10:37 am, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
><xparr...@gmai l.comwrote in
messagenews:11 *************** *******@b28g200 0cwb.googlegrou ps.com...
>I know that I can get the SERVER port number like this:
HttpContext.Cur rent.Request.Se rverVariables["SERVER_POR T"]
My question is how do I get the remote CLIENT port number?I'm not sure which port you're
referring to here...???

Oct 18 '06 #8
<xp******@gmail .comwrote in message
news:11******** ************@i3 g2000cwc.google groups.com...
I'm referring to the client TCP/IP port number that the http response
will be sent on. If I go onto the web server and use a utility like
netstat I can see both sides of the connection -- usually, the server
port number will be 80 or 443 and the client will be a high port
number. I'm wondering if there is a way to access this port number via
code.
Oh right...

Hmm - IIRC this is an entirely random port picked from a pool of available
ports between something like 1024 and 65536, but I don't think there's any
way of finding out its number through the standard HttpRequest /
HttpResponse connectivity.

AAMOI, what possible use could this number be to you...?
Oct 18 '06 #9
Hmm - IIRC this is an entirely randomportpicke d from a pool of available
ports between something like 1024 and 65536, but I don't think there's any
way of finding out its number through the standard HttpRequest /
HttpResponse connectivity.

AAMOI, what possible use could this number be to you...?
To answer your question -- The remote port can be used to determine the
machine that a request was originally routed from behind a NAT enabled
router. When NAT is used, all requests behind a router appear to come
from the same IP address. The only thing that differs is the port
number. NAT uses the port number to route the request back to the
proper machine on the private subnet.

In response to previous posts, the request would rarely be sent back to
the client on port 80 or 443. These ports would only be open on the
server machine. In fact, some personal firewalls would block these
ports entirely on a client PC. Usually the client initiates the
request and chooses a random high number port for its side of the
socket and connects to a known port on the server (80,443). When the
response is returned from the server it it sent back via the high
numbered client port for which it originated. You can observe this by
running "netstat -N" from the command line on a web server. It will
show all open client connections to the web server. You will see the
high numbered remote ports with the client address and standard ports
80 and 443 on the server side. Hope this clears up the port
confusion.
>From the responses so far, it sounds like there is no easy way to
access this information via ASP.net.

Oct 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2497
by: Fredric Ragnar | last post by:
Hi, I am making a prototype system with Remoting in the bottom of the system. An XML Web Service is using the remote object on an IIS to present data. I am using a TcpChannel for communicating between the XML Web Service and the host for the remote object. Within the host a port is defined and the channel registered. It starts listening for requests. The destination port is therefore clearly defined.
9
2703
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql 2000. In my case the server I couldn't reach was across a vpn connection, behind ISA server 2000, (which had port 1433 open). The answer was in this post:...
4
5772
by: tommaso.gastaldi | last post by:
If one does not configure a virtual dir as an IIS application, he/she receives the common error: ---------------------------------------- Server Error in '/' Application. .... This error can be caused by a virtual directory not being configured as an application in IIS. ---------------------------------------- Assume that I have a remote site: http://Mysite/MyApps/MyAppDir
3
9554
by: nandan | last post by:
Yes. My client has a proxy server. That much i know. In my application I make two kinds of calls that are affected by the proxy server I finally got the webservice call working. But my httpwebrequest.GetReponse() function call throws the above error. So here's what i do in the case it works.. //THIS WORKS
10
15959
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp
1
3524
by: koole | last post by:
HI, This is the present situation. 1.I have Db2 9.1 installed on 1 AIX machines(server).I have database created and everything is runniing. 2.I have another server with db2 9.1 and I want to connect from this machine to above machine.,
8
7283
by: John | last post by:
Hi We had an sbs 2003 with isa 2000 server. We wre able to access a remote sql server (hosted at our web host) just fine. We replaced the server with a new sbs 2003 r2 with isa 2004 server and even though I have opened port 1433 in isa 2004 we can't access the remote sql server anymore. Where can I look for any blocks? Many Thanks
1
5407
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi, After some search around, trying to get my SQL Management studio (running on Vista) to connect to a remote SQL server instance, i finally nailed it. Your management studio will refuse to connect onto the remote instances of SQL sever... One of the easiest way around this is to disable your firewall and then connect usually. Well...this isint really a very good idea, and will drive you nuts atleast 2-5 times a day. To overcome this...
1
9304
by: malooga | last post by:
Hello, I'm having a problem connecting to DB2 on a remote iSeries host from a Linux server, both of which reside on my company's internal network. I'm using the IBM Linux Client V9.1. When I try to connect to the remote host using a simple connect statement, DB2 hangs. The connection statement I'm using (I've obviously obscured the parameter names): $ ./db2 connect to DATABASENAME user USERNAME using PASSWORD;
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.