❔ 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
Anchy2y ago
what parameters are you using for the tcp listener?
king_star6368
king_star63682y ago
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);
}
king_star6368
king_star63682y ago
i use public IP and turn off firewall
Anchy
Anchy2y ago
have you forwarded the port in your routers firewall
king_star6368
king_star63682y ago
yes i make them it work but for client side server side AcceptTcpClient stock Wait in AcceptTcpClient
Anchy
Anchy2y ago
start the server and use an external port checker to verify the port is indeed open
king_star6368
king_star63682y ago
if you want i show you the app
Anchy
Anchy2y ago
sure
king_star6368
king_star63682y ago
i in voice dev-vc-0
Anchy
Anchy2y ago
I cannot join at the moment on my phone
king_star6368
king_star63682y ago
oh ok
Anchy
Anchy2y ago
😄
king_star6368
king_star63682y ago
this is all code
Anchy
Anchy2y ago
right, and what port are you binding to?
king_star6368
king_star63682y ago
my router prot i make them
Anchy
Anchy2y ago
yes but what port are you trying to use
king_star6368
king_star63682y ago
i do not understand . If you mean the number 80
Anchy
Anchy2y ago
is it possible the port is in use? 80 is a widely used port for http
king_star6368
king_star63682y ago
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
Accord2y 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
More Posts
❔ EmguCV with .NET MAUIHello everyone. I can access the camera with VideoCapture but I couldn't transfer it to Mat object✅ How to register all Automapper profiles from one project in the Startup class of a second projectHi friends, I have a solution with the structure in the screen-shot attachement, I use Automapper ❔ Doing freelance work. What is the right skill level to start it? Doing it to develop skills?Hello! I'm looking for some advice on this subject. I'm currently working on small projects to devel❔ Documentation on the AOT runtime's internal type system (EEType)?I'm trying to create my own operating system in C#, using the ZeroSharp repository (https://github.c❔ Page debugging twice in razor pages PageRouteModelConvention`public class CultureTemplatePageRouteModelConvention : IPageRouteModelConvention { public void ✅ What should I do now?Hello! I've watched a c# tutorial for beginners by freeCodeCamp.org which was 4 hours long. And now ❔ My code cant write to a certain pathBasically i have a script to download a file from github into a specific folder and when i click the❔ JSON Serialization Weird ModelHey all, I have a situation where I need to approach a REST service with a POST containing either XM✅ EntityFrameworkCore listsThis has probably been asked before, but is it possible to store a `List<T>` in a npsql database usi❔ ✅ filtering, dissecting a string for processingNot sure how to search for this online, so I'm asking here. I have a user input system, and I want t