Cant connect to a remote pc not over LAN but over Internet [modified]
-
Hi!! I need some help... i cant connect to a a client running on a pc over net.. i got 2 programs one client and one server... running successfully when i give my local IP address... But when i change the local IP address to External IP address... it not working.. plz help me.. i want it to run over internet... Thanks in advance... client:
using System; using System.IO; using System.Net; using System.Text; using System.Net.Sockets; public class clnt { public static void Main() { try { TcpClient tcpclnt = new TcpClient(); Console.WriteLine("Connecting....."); tcpclnt.Connect("120.56.168.186", 8001); // use the ipaddress as in the server program Console.WriteLine("Connected"); Console.Write("Enter the string to be transmitted : "); String str=Console.ReadLine(); Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen= new ASCIIEncoding(); byte[] ba=asen.GetBytes(str); Console.WriteLine("Transmitting....."); stm.Write(ba,0,ba.Length); byte[] bb=new byte[100]; int k=stm.Read(bb,0,100); for (int i=0;i Server: `using System; using System.Text; using System.Net; using System.Net.Sockets; public class serv { public static void Main() { try { IPAddress ipAd = IPAddress.Parse("120.56.168.186"); //use local m/c IP address, and use the same in the client TcpListener myList=new TcpListener(ipAd,8001); myList.Start(); Console.WriteLine("The server is running at port 8001..."); Console.WriteLine("The local End point is :" + myList.LocalEndpoint ); Console.WriteLine("Waiting for a connection....."); Socket s=myList.AcceptSocket(); Console.WriteLine("Connection accepted from "+s.RemoteEndPoint); byte[] b=new byte[100]; int k=s.Receive(b); Console.WriteLine("Recieved..."); for (int i=0;i`
-
Hi!! I need some help... i cant connect to a a client running on a pc over net.. i got 2 programs one client and one server... running successfully when i give my local IP address... But when i change the local IP address to External IP address... it not working.. plz help me.. i want it to run over internet... Thanks in advance... client:
using System; using System.IO; using System.Net; using System.Text; using System.Net.Sockets; public class clnt { public static void Main() { try { TcpClient tcpclnt = new TcpClient(); Console.WriteLine("Connecting....."); tcpclnt.Connect("120.56.168.186", 8001); // use the ipaddress as in the server program Console.WriteLine("Connected"); Console.Write("Enter the string to be transmitted : "); String str=Console.ReadLine(); Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen= new ASCIIEncoding(); byte[] ba=asen.GetBytes(str); Console.WriteLine("Transmitting....."); stm.Write(ba,0,ba.Length); byte[] bb=new byte[100]; int k=stm.Read(bb,0,100); for (int i=0;i Server: `using System; using System.Text; using System.Net; using System.Net.Sockets; public class serv { public static void Main() { try { IPAddress ipAd = IPAddress.Parse("120.56.168.186"); //use local m/c IP address, and use the same in the client TcpListener myList=new TcpListener(ipAd,8001); myList.Start(); Console.WriteLine("The server is running at port 8001..."); Console.WriteLine("The local End point is :" + myList.LocalEndpoint ); Console.WriteLine("Waiting for a connection....."); Socket s=myList.AcceptSocket(); Console.WriteLine("Connection accepted from "+s.RemoteEndPoint); byte[] b=new byte[100]; int k=s.Receive(b); Console.WriteLine("Recieved..."); for (int i=0;i`
Access to your remote PC is likely being blocked by a firewall. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Hi!! I need some help... i cant connect to a a client running on a pc over net.. i got 2 programs one client and one server... running successfully when i give my local IP address... But when i change the local IP address to External IP address... it not working.. plz help me.. i want it to run over internet... Thanks in advance... client:
using System; using System.IO; using System.Net; using System.Text; using System.Net.Sockets; public class clnt { public static void Main() { try { TcpClient tcpclnt = new TcpClient(); Console.WriteLine("Connecting....."); tcpclnt.Connect("120.56.168.186", 8001); // use the ipaddress as in the server program Console.WriteLine("Connected"); Console.Write("Enter the string to be transmitted : "); String str=Console.ReadLine(); Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen= new ASCIIEncoding(); byte[] ba=asen.GetBytes(str); Console.WriteLine("Transmitting....."); stm.Write(ba,0,ba.Length); byte[] bb=new byte[100]; int k=stm.Read(bb,0,100); for (int i=0;i Server: `using System; using System.Text; using System.Net; using System.Net.Sockets; public class serv { public static void Main() { try { IPAddress ipAd = IPAddress.Parse("120.56.168.186"); //use local m/c IP address, and use the same in the client TcpListener myList=new TcpListener(ipAd,8001); myList.Start(); Console.WriteLine("The server is running at port 8001..."); Console.WriteLine("The local End point is :" + myList.LocalEndpoint ); Console.WriteLine("Waiting for a connection....."); Socket s=myList.AcceptSocket(); Console.WriteLine("Connection accepted from "+s.RemoteEndPoint); byte[] b=new byte[100]; int k=s.Receive(b); Console.WriteLine("Recieved..."); for (int i=0;i`
...and is the address of the remote PC really that PC's address and not the address of the modem?
-
Access to your remote PC is likely being blocked by a firewall. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
...and is the address of the remote PC really that PC's address and not the address of the modem?