Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to encrypt an xml file? Pin
Orjan Westin10-Aug-10 2:34
professionalOrjan Westin10-Aug-10 2:34 
QuestionApplication Switching via a HotKey Pin
gmhanna9-Aug-10 6:53
gmhanna9-Aug-10 6:53 
AnswerRe: Application Switching via a HotKey Pin
Ravi Bhavnani9-Aug-10 7:22
professionalRavi Bhavnani9-Aug-10 7:22 
GeneralRe: Application Switching via a HotKey Pin
gmhanna9-Aug-10 7:41
gmhanna9-Aug-10 7:41 
GeneralRe: Application Switching via a HotKey Pin
Ravi Bhavnani9-Aug-10 7:45
professionalRavi Bhavnani9-Aug-10 7:45 
GeneralRe: Application Switching via a HotKey Pin
T M Gray9-Aug-10 9:51
T M Gray9-Aug-10 9:51 
AnswerRe: Application Switching via a HotKey Pin
Luc Pattyn9-Aug-10 7:56
sitebuilderLuc Pattyn9-Aug-10 7:56 
QuestionCant connect to a remote pc not over LAN but over Internet [modified] Pin
ayandelhi9-Aug-10 6:34
ayandelhi9-Aug-10 6:34 
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:
<code>
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<k;i++)
Console.Write(Convert.ToChar(bb[i]));

tcpclnt.Close();
Console.ReadLine();
}

catch (Exception e) {
Console.WriteLine("Error..... " + e.StackTrace);
Console.ReadLine();
}
}

}
</code>

Server:
<code>
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<k;i++)
Console.Write(Convert.ToChar(b[i]));

ASCIIEncoding asen=new ASCIIEncoding();
s.Send(asen.GetBytes("The string was recieved by the server."));
Console.WriteLine("\r\nSent Acknowledgement");

s.Close();
myList.Stop();
Console.ReadLine();
}

catch (Exception e) {
Console.WriteLine("Error..... " + e.StackTrace); Console.ReadLine();
}
}

}

</code>




Can u tell me how shud i use a DNS server... how can i use it to use my program over the internet... plz.. i need to know this.. this is bugging me a lot..



-- Modified Tuesday, August 10, 2010 10:50 AM
AnswerRe: Cant connect to a remote pc not over LAN but over Internet Pin
Ravi Bhavnani9-Aug-10 7:30
professionalRavi Bhavnani9-Aug-10 7:30 
GeneralRe: Cant connect to a remote pc not over LAN but over Internet Pin
ayandelhi10-Aug-10 2:41
ayandelhi10-Aug-10 2:41 
AnswerRe: Cant connect to a remote pc not over LAN but over Internet Pin
Bernhard Hiller9-Aug-10 20:50
Bernhard Hiller9-Aug-10 20:50 
GeneralRe: Cant connect to a remote pc not over LAN but over Internet Pin
ayandelhi10-Aug-10 2:42
ayandelhi10-Aug-10 2:42 
QuestionTest Automation application (white library - Tutorials) Pin
arun_pk9-Aug-10 1:26
arun_pk9-Aug-10 1:26 
AnswerRe: Test Automation application (white library - Tutorials) Pin
Dave Kreskowiak9-Aug-10 3:44
mveDave Kreskowiak9-Aug-10 3:44 
AnswerRe: Test Automation application (white library - Tutorials) Pin
Luc Pattyn9-Aug-10 4:32
sitebuilderLuc Pattyn9-Aug-10 4:32 
GeneralRe: Test Automation application (white library - Tutorials) Pin
JHizzle9-Aug-10 5:16
JHizzle9-Aug-10 5:16 
GeneralRe: Test Automation application (white library - Tutorials) Pin
arun_pk9-Aug-10 19:17
arun_pk9-Aug-10 19:17 
AnswerRe: Test Automation application (white library - Tutorials) Pin
T M Gray9-Aug-10 6:10
T M Gray9-Aug-10 6:10 
GeneralRe: Test Automation application (white library - Tutorials) Pin
arun_pk9-Aug-10 19:15
arun_pk9-Aug-10 19:15 
Questionis this my ocx certainly? Pin
mersad008-Aug-10 23:54
mersad008-Aug-10 23:54 
AnswerRe: is this my ocx certainly? Pin
Eddy Vluggen9-Aug-10 5:45
professionalEddy Vluggen9-Aug-10 5:45 
AnswerRe: is this my ocx certainly? Pin
T M Gray9-Aug-10 6:07
T M Gray9-Aug-10 6:07 
Questionassembly info checker class!!!!! Pin
mersad009-Aug-10 7:35
mersad009-Aug-10 7:35 
AnswerRe: assembly info checker class!!!!! Pin
T M Gray9-Aug-10 9:42
T M Gray9-Aug-10 9:42 
QuestionDisplay gif image in button click ( windows application ) Pin
Krishna Varadharajan8-Aug-10 23:49
Krishna Varadharajan8-Aug-10 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.