Click here to Skip to main content
15,886,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written several codes where where communication is via socket and listening is done at a port, but with certain C++ codes that I have stumbled at on the internet like Microsoft Rest Desk and [^] I see mention of listening at a url.

The question is:
What url is the listening being done at? Is it the url of the server script that is suppose to do the listening or that of some other file or script.

If the url to listen at is that is of the script doing the listening, why can't it programatically figure out its own url?

What I have tried:

I tried googling for an explanation but got no relevant result. Tried reading up MSDN, but MSDN did not explain the concept.
Posted
Updated 9-Jul-16 0:04am
Comments
Richard MacCutchan 9-Jul-16 5:48am    
A URL is just an address with some extra information. It is sent to the address on port 80 or 8080, where the server is listening on those ports.

1 solution

Sockets are not listening on URLs but on a single port on one or all interfaces where the interfaces are defined by their IP adresses.

If you for example bind a listening socket to port 80 on the loopback interface 127.0.0.1, the corresponding address will be "localhost:80".

When servicing HTTP requests on this socket, the URL will be "http://localhost:80/".

If you want to service HTTP requests depending on the relative URI part, you need a server process that reads the request and forward it depending on the relative URI. In your previous question you have already used an API that provides such a technique: About HTTP Server API (Windows)[^].

It will create listening sockets internally and allows handling of the requests by additional functions.
 
Share this answer
 
Comments
Gbenbam 9-Jul-16 7:50am    
This is quite illuminating.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900