Results 1 to 2 of 2
Hi to everyone, I'm Alejandro from Argentina. I'm programming a client/server application for the University and my problem is that i make it function in a local network, but i ...
- 10-09-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 1
Socket problems
Hi to everyone, I'm Alejandro from Argentina. I'm programming a client/server application for the University and my problem is that i make it function in a local network, but i don't understand how to make it work accross internet. I don't have a public ip so if i puy the serer in my computer and the client in my friend computer how does it works? How can i accept connections accross internet?
do you want the source code?
Thanks and sorry for my English.
- 10-09-2008 #2
Alejandro, your first step is to connect your computer to the internet. You've probably already done this. If you can do this at the command line and see wikipedia's main page, then the first step is complete:
The next step, inside your program, is to translate the desired host name into an IP address. There are several ways to do this.Code:lynx http://www.wikipedia.org
- The simplest way is to use gethostbyname().
- A way more likely to be thread safe (if you're using POSIX threads) is to use gethostbyname_r().
- A better way is to use getaddrinfo(). This way you'll be ready for IPV6, but the programming will be a little more complex.
Once you have the IP address, you're good to go. Use it the same way you'd use the IP address of a local host.
I highly recommend that you run (not walk) to your nearest bookseller and purchase the book UNIX Network Programming, volume 1, by W. Richard Stevens of happy memory, published by Addison Wesley. It contains much information that will save you time in the long run.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote