J
Jon Slaughter
I can't seem to get these to work over my router. I have all the ports open
and ftp works from outside. Is there anything special I have to do or what?
(my app does work over the LAN though) I'm using the bare basics and the app
is very simple. I was just trying to see how hard it was to do.
// sends and recieves text.
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.AppendText(UserName + ": " + richTextBox2.Text +
"\n");
string s1 = richTextBox2.Text;
w.Write(s1 + "\n");
string s = r.ReadString();
richTextBox1.AppendText("Client: " + s + "\n");
richTextBox2.Clear();
}
// Starts Server
private void button3_Click(object sender, EventArgs e)
{
richTextBox1.AppendText("Starting Server...\n");
listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 21);
listener.Start();
try
{
client = listener.AcceptTcpClient();
richTextBox1.AppendText("Client Connected...\n");
stream = client.GetStream();
w = new BinaryWriter(stream);
r = new BinaryReader(stream);
}
catch (Exception ex)
{
richTextBox1.AppendText("\n" + ex.ToString());
}
}
// Starts Client
private void button4_Click(object sender, EventArgs e)
{
string IP = numericUpDown1.Value.ToString() + "." +
numericUpDown2.Value.ToString() + "." + numericUpDown3.Value.ToString() +
"." + numericUpDown4.Value.ToString();
client = new TcpClient();
client.Connect(IPAddress.Parse(IP), 21);
stream = client.GetStream();
w = new BinaryWriter(stream);
r = new BinaryReader(stream);
}
}
}
(again, the code isn't ment to be a good implementation of a client/server
but just something very basic. basically a very crude chat program. No
asynchronous IO or anything like that).
Thanks,
Jon
and ftp works from outside. Is there anything special I have to do or what?
(my app does work over the LAN though) I'm using the bare basics and the app
is very simple. I was just trying to see how hard it was to do.
// sends and recieves text.
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.AppendText(UserName + ": " + richTextBox2.Text +
"\n");
string s1 = richTextBox2.Text;
w.Write(s1 + "\n");
string s = r.ReadString();
richTextBox1.AppendText("Client: " + s + "\n");
richTextBox2.Clear();
}
// Starts Server
private void button3_Click(object sender, EventArgs e)
{
richTextBox1.AppendText("Starting Server...\n");
listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 21);
listener.Start();
try
{
client = listener.AcceptTcpClient();
richTextBox1.AppendText("Client Connected...\n");
stream = client.GetStream();
w = new BinaryWriter(stream);
r = new BinaryReader(stream);
}
catch (Exception ex)
{
richTextBox1.AppendText("\n" + ex.ToString());
}
}
// Starts Client
private void button4_Click(object sender, EventArgs e)
{
string IP = numericUpDown1.Value.ToString() + "." +
numericUpDown2.Value.ToString() + "." + numericUpDown3.Value.ToString() +
"." + numericUpDown4.Value.ToString();
client = new TcpClient();
client.Connect(IPAddress.Parse(IP), 21);
stream = client.GetStream();
w = new BinaryWriter(stream);
r = new BinaryReader(stream);
}
}
}
(again, the code isn't ment to be a good implementation of a client/server
but just something very basic. basically a very crude chat program. No
asynchronous IO or anything like that).
Thanks,
Jon