Hello people. I am trying to develope a html link that when i click on ym web site will contact my c+ server. In this link i wish to tack on the end a variable like how people do it in php
heres an example
www.site.com/?variable
I know so far that if my server is running and i type local host into my web browser that it will make a connetion with my server. So the concept is working right. This will only work with my loopback address 127.0.0.1 and local host which are the same thing. If i try to use my ip address for this, it will not work. this is veyr annoying and i dont understand why if my loopback address works why wont my ip. I need to be able to use my ip to finish this concept to fully work.
Ive come to a few conclusions. Either it is a port forwarding problem or i need to use a domain name to do that. I want to do all of this without having to upload a web site, and all. I hear it is possable to type your ip address into a browser and connect with your home server. please help thank you and good bye.
2 replies to this topic
#1
Posted 14 February 2012 - 07:11 PM
|
|
|
#2
Posted 15 February 2012 - 02:42 AM
Most likely you're only listening on localhost. Usually if you specify 0.0.0.0 address, it will listen on all interfaces.
A conclusion is where you got tired of thinking.
#define class struct // All is public.
#3
Posted 11 April 2012 - 10:12 PM
I just made a testing of the concept you said and found that it is working on my machine.
Here is the C# code...
And while put 192.168.132.1:7799 in a tab in my chrome browser and hit it, I got the following data from browser...
GET / HTTP/1.1
Host: 192.168.132.1:7799
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Here is the C# code...
string hostname = Dns.GetHostName(); IPAddress ip = Dns.GetHostByName(hostname).AddressList[0]; /* This ip address is 192.168.1.32 */ IPEndPoint endpoint = new IPEndPoint(ip, 7799); //saving ip &port number Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //installing a new socket! socket.Bind(endpoint); //making bind function by nameing it ipendpoint!!! socket.Listen(5); //number of syste's it's going to listen to.... socket = socket.Accept(); //accept's things. we will get client end to communicate with client byte[] data = new byte[50000]; //makeing array to get data from client!!! socket.Receive(data); //receive the"data" from client! textBox1.AppendText(Encoding.ASCII.GetString(data)); // let us see what we got from browser
And while put 192.168.132.1:7799 in a tab in my chrome browser and hit it, I got the following data from browser...
GET / HTTP/1.1
Host: 192.168.132.1:7799
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










