Hello everyone.
I have recently finished a Winsock Server, and a Winsock Client. The problem is, I do not know what type of a domain/and or server I would have to buy to be able to connect my Winsock Server, to it.

I already know that Winsock uses the inet_addr() function to define an IP address, which tells the server where to "listen" at; what I do not know, is how to go about "buying" an IP address that people can connect to.

Example:
What is preventing me from using google.com's IP address as the place for my server to "listen" at for connections?

What I have already tried, was to use a "free" web host service (000webhost.com). The service provided me with an IP address to my free website. I used that IP address in my Winsock Server; however, the application was unsuccessful to "bind" a socket to that IP address/port.

My winsock server was able to utilize

htonl (INADDR_ANY);

in order to connect two clients with each other (over MY home pc's IP address). However, when a remote IP address was used via the

inet_address()

, function, my program was unable to "bind" a socket to that IP address/port.


My question is, is it because the IP address was "free" that it could not be used to bind a socket to? Or, is it that I have be granted special privilidges by a Web Host providert to be able to use a specified IP address as a valid domain to connect to?

If I have to be granted special privilidges, what type of service would I have to buy? An ordinary website? Or, would I have to buy a dedicated server IP or something like that.

For testing out the two programs you could do them both on the same computer. For more extensive tests use two computers (or computer and laptop) you connected via LAN. I don't think you can make your server program run on someone else's computer without their permission.

You can't just listen on a foreign IP address - the address must be one of your own network addresses, i.e. one that your computer is connected to the network with.
If you use say, an address of a Google server, it won't do you much good: the internet routers will route all packets to the Google server, but never to you. Same for the webhost service - the messages will always be sent to the webhost server.
So in order for this to work, your program needs to run on their server. You can simply rent one (virtual servers are usually quite cheap) or you can be the server yourself - then you'll need to connect to your own IP address. If you have a router, you'll probably need to add a port forwarding rule.

Thank you for your reply Aranarth.

Is it possible for you to expand on how exactly I would go about "running" a program on a webhost server? I have recently bought a dedicated server, and so, I would like to know if it is possible to run a server.exe application on it (and not from my home computer). Thank you in advance.

You should have received login info for your server when you purchased it.
If the server runs Linux, you can login to a remote shell via SSH.
If it runs Windows, I believe the "remote desktop" tool is the preferred way to access your server.

To copy files on your server (Linux), use scp/WinSCP or mount the server's file system directly.
I'm sure there are simple ways to copy files remotely on a Windows server too. If in question, just upload your program somewhere and download it on the server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.