❔ TCP Connect To Public iP

I Make a simple app for chat(it work in local) but dos not work for connect to public IP
22 Replies
Anchy
Anchyβ€’2y ago
what parameters are you using for the tcp listener?
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
C#
server side
try
{
//Tls = new TcpListener(IPAddress.Parse(Tbox_Ip.Text), int.Parse(TBox_Prot.Text));
Tls = new TcpListener(IPAddress.Any, int.Parse(TBox_Prot.Text));
Tls.Start();
tcp = Tls.AcceptTcpClient();
stream = tcp.GetStream();
data = new Data();
backgroundWorker1.WorkerSupportsCancellation = false;
backgroundWorker1.RunWorkerAsync();
backgroundWorker2.WorkerSupportsCancellation = false;
backgroundWorker2.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
C#
server side
try
{
//Tls = new TcpListener(IPAddress.Parse(Tbox_Ip.Text), int.Parse(TBox_Prot.Text));
Tls = new TcpListener(IPAddress.Any, int.Parse(TBox_Prot.Text));
Tls.Start();
tcp = Tls.AcceptTcpClient();
stream = tcp.GetStream();
data = new Data();
backgroundWorker1.WorkerSupportsCancellation = false;
backgroundWorker1.RunWorkerAsync();
backgroundWorker2.WorkerSupportsCancellation = false;
backgroundWorker2.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
C#
Client Side
try
{
tcp = new TcpClient();
tcp.Connect(new IPEndPoint(IPAddress.Parse(Tbox_Ip.Text), int.Parse(TBox_Prot.Text)));
//tcp.Connect(Tbox_Ip.Text, int.Parse(TBox_Prot.Text));
stream = tcp.GetStream();
data = new Data();
backgroundWorker1.WorkerSupportsCancellation = false;
backgroundWorker1.RunWorkerAsync();
backgroundWorker2.WorkerSupportsCancellation = false;
backgroundWorker2.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
C#
Client Side
try
{
tcp = new TcpClient();
tcp.Connect(new IPEndPoint(IPAddress.Parse(Tbox_Ip.Text), int.Parse(TBox_Prot.Text)));
//tcp.Connect(Tbox_Ip.Text, int.Parse(TBox_Prot.Text));
stream = tcp.GetStream();
data = new Data();
backgroundWorker1.WorkerSupportsCancellation = false;
backgroundWorker1.RunWorkerAsync();
backgroundWorker2.WorkerSupportsCancellation = false;
backgroundWorker2.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
i use public IP and turn off firewall
Anchy
Anchyβ€’2y ago
have you forwarded the port in your routers firewall
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
yes i make them it work but for client side server side AcceptTcpClient stock Wait in AcceptTcpClient
Anchy
Anchyβ€’2y ago
start the server and use an external port checker to verify the port is indeed open
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
if you want i show you the app
Anchy
Anchyβ€’2y ago
sure
Anchy
Anchyβ€’2y ago
I cannot join at the moment on my phone
Anchy
Anchyβ€’2y ago
πŸ˜„
Anchy
Anchyβ€’2y ago
right, and what port are you binding to?
Anchy
Anchyβ€’2y ago
yes but what port are you trying to use
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
i do not understand . If you mean the number 80
Anchy
Anchyβ€’2y ago
is it possible the port is in use? 80 is a widely used port for http
π•Άπ–Žπ–“π–Œ_π–˜π–™π–†π–—
I mean, I'll find and use an unused port from here.(https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers)
List of TCP and UDP port numbers
This is a list of TCP and UDP port numbers used by protocols for operation of network applications. The Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) only need one port for duplex, bidirectional traffic. They usually use port numbers that match the services of the corresponding TCP or UDP implementation, if they exist....
Accord
Accordβ€’2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server