Discussion:
How to get IP address will be used by HTTP in C++
(too old to reply)
j***@yahoo.com
2008-02-01 22:22:03 UTC
Permalink
At the client side, when my client machine talks to server, the server
will see the IP address of my machine as part of HTTP request. My
question is how I can programmatically get this IP address which will
be used in HTTP request? I could use gethostname to get IP addresses,
but that is a list. How can I tell which one will be used?

Thanks very much in advance.

Leo
Volodymyr Shcherbyna
2008-02-01 23:22:55 UTC
Permalink
Use getsockname(...) in your client on connected socket to retrieve local
(source) address which is used by system.
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by j***@yahoo.com
At the client side, when my client machine talks to server, the server
will see the IP address of my machine as part of HTTP request. My
question is how I can programmatically get this IP address which will
be used in HTTP request? I could use gethostname to get IP addresses,
but that is a list. How can I tell which one will be used?
Thanks very much in advance.
Leo
j***@yahoo.com
2008-02-02 00:34:33 UTC
Permalink
Basically I need to get the packet source IP address seen by
the server. The locally IP addres may be different from IP address
seen by
the server (consider the ISP case), right? Will getsockname still
work?

Leo
Kun Niu
2008-02-02 02:12:00 UTC
Permalink
In such case, you should implement your own protocol to get the nat ip used
by the client.
Add an HTTP header etc.
Hope this helps.
Post by j***@yahoo.com
Basically I need to get the packet source IP address seen by
the server. The locally IP addres may be different from IP address
seen by
the server (consider the ISP case), right? Will getsockname still
work?
Leo
Volodymyr Shcherbyna
2008-02-02 12:17:38 UTC
Permalink
I don't think so. You may return the global address of a client from server
in a header.
--
V
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by j***@yahoo.com
Basically I need to get the packet source IP address seen by
the server. The locally IP addres may be different from IP address
seen by
the server (consider the ISP case), right? Will getsockname still
work?
Leo
Alexander Nickolov
2008-02-15 20:56:20 UTC
Permalink
You can try talking the IGD protocol to a home Internet router
(more commonly known as UPnP for routers). Of course that only
works with home Internet routers where UPnP is enabled...

You can also talk to a public STUN or STUNT server.

Finally, you can have your own server return that information to
your clients (typically you'd just host a STUN/STUNT server).
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: ***@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
Post by j***@yahoo.com
Basically I need to get the packet source IP address seen by
the server. The locally IP addres may be different from IP address
seen by
the server (consider the ISP case), right? Will getsockname still
work?
Leo
Scott Landsman
2011-03-23 20:48:33 UTC
Permalink
I have a job opening in Hunt Valley, MD for a Multiplayer Developer. They do offer relo reimburrsement and I just thought by reading this old post you may be a fit. If you are interested, please send me an email at ***@sigsum.com or call me at 410-828-0777.

The role is responsible for implementing multiplayer game systems, including matchmaking, integration with 3rd party support libraries and working closely with design, engineering and quality assurance. The programmer will take point on all multiplayer tasks, coordinating with the development team to identify objectives and see them through to completion.



Requirements:

* Understands deterministic peer-to-peer simulations often used in
strategy games
* B.S. In Computer Science or equivalent industry experience
* Must be proficient with C++
* Experience with the entire development cycle, should have
shipped multiple titles from start to finish
* Intimate understanding of basic IP network protocols (TCP and
UDP)
* Working experience with NAT traversal protocols (STUN, STUNT,
for example)
* Familiarity with 3rd party libraries such as Steam and GameSpy
* Basic understanding of user interface design/architecture

Responsibilities:

* Maintain, improve and/or re-factor existing systems
* Improve overall code quality, performance and stability
* Support existing matchmaking systems, improving the player
experience
Post by Volodymyr Shcherbyna
Use getsockname(...) in your client on connected socket to retrieve local
(source) address which is used by system.
--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Kun Niu
In such case, you should implement your own protocol to get the nat ip used
by the client.
Add an HTTP header etc.
Hope this helps.
I do not think so. You may return the global address of a client from server
in a header.
--
V
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by j***@yahoo.com
At the client side, when my client machine talks to server, the server
will see the IP address of my machine as part of HTTP request. My
question is how I can programmatically get this IP address which will
be used in HTTP request? I could use gethostname to get IP addresses,
but that is a list. How can I tell which one will be used?
Thanks very much in advance.
Leo
Post by j***@yahoo.com
Basically I need to get the packet source IP address seen by
the server. The locally IP addres may be different from IP address
seen by
the server (consider the ISP case), right? Will getsockname still
work?
Leo
Post by Alexander Nickolov
You can try talking the IGD protocol to a home Internet router
(more commonly known as UPnP for routers). Of course that only
works with home Internet routers where UPnP is enabled...
You can also talk to a public STUN or STUNT server.
Finally, you can have your own server return that information to
your clients (typically you'd just host a STUN/STUNT server).
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
Loading...