question

HemanthB-9452 avatar image
0 Votes"
HemanthB-9452 asked cooldadtx answered

Send Text between two different computers C#

Hi, I've been searching the web for this answer for a long time, but I don't get any useful answer. I want create an app which can send data to the same app however in a different computer with or without the same internet/wifi connection. I want this in such a way that there is no need to disable any firewall or any anti-virus software. I've tried many sources but those sources just keep throwing exceptions. Kindly help.

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

I'm afraid there is no way to accept incoming requests from the internet without first making an exception in the firewall. Doing otherwise would be a huge security hole as anyone could then write an app that allowed malicious code to do this exact thing. Hence you cannot accept incoming network requests without a firewall exception. No workaround to this that would be in any way secure.

You can initiate outgoing requests potentially without a firewall rule change but on most computers outgoing requests are also blocked by default. This is, again, for security reasons. The only program that wouldn't want you to do this is malicious software. Most apps simply add a rule when they install themselves so this shouldn't be an issue for a user.

As for communicating across the Internet there are many different RPC options available. If you don't want to have to configure custom port stuff then HTTPS probably is the easiest but this requires you running a web server. For simple communications using a custom protocol then a regular TCP client/server app is sufficient. If you are building a "chat" like app then UDP is probably better but at the cost of reliability. There are plenty of examples online on how to build these types of apps in C#. Unfortunately they all require that you write a reasonable amount of code and you must understand how TCP/UDP works.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.