I'm developing a simple p2p program that is meant to work over the Internet, this works fine on a LAN, but when a router and internet connection are involved nothing gets to the machine. I am aware that this is a network question more than a C# question, but I can't have users of this program set up port forwarding every time they want to use the software. I have read the other posts regarding this, but most seem old, so I was wondering if VS2010 has any way to tackle this.
Note: The code for the networking is already complete, and uses TCPLsteners and Clients, so I can't switch to any other method...
Thanks,
PM
Is there a UPnP Library for .NET (C# or VB.NET)? looks promising...
Related
As per my knowledge, I knew that messages can posted from one application to other application using "SendMessage" or "PostMessage".
I tried using SignalR to communicate b/w the applications. The problem here i found was server should be launched as a console application and clients will be my winforms. Ideally I don't want to show this console application as it seems to be weird for the user. If there is any work around for this approach please suggest.
After signalR I came across EventAggregrator in c#. Can we use EventAggregrator to communicate b/w two different C# applications? If yes could some one give an example on how to do this.
Until a few years ago, Socket class was the right way to do this. There are probably more modern, robust and easier ways to achieve the same result nowadays, but you may want to look at what's under the hood.
Socket class on MSDN:
https://msdn.microsoft.com/it-it/library/system.net.sockets.socket%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
Client-server example on CodeProject:
https://www.codeproject.com/articles/463947/working-with-sockets-in-csharp
My question today is how to develop stun and turn servers for webrtc peer-to-peer application in c# is there any library supports this, I can't find any example or resource to obtain this.
Please help me with this because it took me too much time searching with no luck.
I tried OfficeSip and didn't work also I tried coturn over cygwin but didn't work.
I'm not sure if there's any STUN/TURN server or library implemented in C#.
The ones that I know of are
coturn
PJNATH
STUNTMAN
go-stun
ReTurn
turnover
On the coturn page you can see a list of all the RFC that has to be implemented.
Frankly, I would not commit to such a huge task of implementing a TURN/STUN server. If you need one that works in Windows, and none of these work, you can try to run it in a VM or something like Docker.
I want to write a method in C# to check which applications in my machine/server are using internet connection at a particular point in time and if possible, how much bandwidth they are using. Can anyone please help me get a head start on this?
I decided to write an answer because comments are too small.
Well, reading other Q&A on stackoverflow and looking around on the internet, I didn't find a simple solution for your problem.
Actually, for .NET processes is really simple, you just need to retrieve informations from ".NET CLR Networking - Bytes Received/Bytes Sent" performance counters, as shown in this Q&A
But in general, getting per-process used bandwidth isn't an easy work.
For example "Microsoft Network Monitor" sniffer can trace the process that generates internet packets only for TCP traffic, because probably it maps IP-port pairs with processes using them (or something similar, TCP is a connected protocol so it is simpler).
Anyway if you want to give it a try you can use the exposed API (look at this blog entry for some hint).
However, as suggested in these Q&A's (LINK 1, LINK 2), the right, and probably the only way, is to write a NDIS/TDI driver that can intercept network traffic and exposing a .NET callable API to it.
The problem is that such drivers can't be written in managed code, and so you need to implement it in C/C++.
Obviously, if you manage to find an already written driver/sniffer exposing a callable API, you can use it.
For example WinPCap has one (and some .NET wrappers like SharpPCap or PCap.Net), but I don't think (not sure) it's able to get packets's source-process information.
As digEmAll noted, in pre-Vista Windows you are reduced to writing your own driver or using a 3-rd party one. In Vista, 2008 and Windows 7 you can use the GetPerTcpConnectionEStats API (there is a large example of its usage on the MSDN page). Resource Monitor relies on this API, together with the older GetTcpTable/GetTcpRow APIs, for extended network statistics.
I found Process Monitor as a very useful tool and it served my purpose so I didnt had to write any code although i am yet to check out whether it gives any API which i can use in my application to get some information I need.
Thanks everyone for helping me out.
We have several legacy components that interact with COM ports, USB etc.
I would like to create a .NET program that would emulate a COM port and log the traffic, relaying it to a WCF service endpoint somewhere or directly into a database. Maybe also wrapping a real COM port kind of like the decorator pattern.
I have looked around and I have found Sourceforge project Com0Com, but it's pretty old API and in c++.
I realize that I can solve this specific problem by creating a line printer driver and never really interacting with the COM ports registered in the system. Some links to that would also be highly appreciated.
Has anybody done this? How do you create system resources in .NET?
You would have to write a driver, that's how Com0Com works. If these components run in-process, you could hijack the Windows API functions, Microsoft's Detours for example.
Either solution requires C/C++, you can't write this code in a managed language. Although detouring could be technically possible, just very hard to get right. You can buy a solution though, your requirements are not uncommon, albeit it dated. Dated enough that finding one might be a bit tricky.
Has anybody done this?
To add to what nobugz said:
When I wrote a COM port emulator, I did it starting from the sample serial port driver in the DDK (serial.sys).
When I wrote a COM port wrapper/logger, I did it starting from the sample parallel port filter driver in the DDK (parport.sys).
My requirement is to write an application to send a file from a remote machine to another machine using internal modem. Both system are connected thru VPN or a internet.
Basically we have two systems both having internal dial up modems. The two systems are connected through either VPN or Internet.
One system should send a file (XML) to another.
I was given the freedom to do it in either C++ or C#. Or is there any other language we can do this easily?
How can I go about this task? Do we need an client/server type application or do we need an app only at the receiving end?
Is there any built in technology available for this type of file transfers using modems?
Since I don't have the programming point of view, my question may not be clear! I tried to put max information on my requirements, but if I am not clear, please ask me.
If you are connected via a VPN, then there are many existing programs available to transfer files between each other. The most well known is FTP. There are many freely available FTP or SFTP packages.
The fact that you are using a modem does not matter. Only that they are in the same network or visible on the internet.
It's been a while, so my memory is fuzzy:
There are modem libraries out there. Find one and use it. No need to reinvent the low level software. I seem to remember using a product from Dialogic (At least I think that was the company). It worked well. I did a quick search and there are 50 companies with that name, but I did see some that mention C, C++ and C# librariers. If you do a little research you'll find what you need.
You will need to learn how to initiate communications between the modems. Almost all modems use the Hayes Modem AT Command Set.
Modems are slow: So pick a compression algorithm before sending data. zlib is an industry favorite.
Your modem library of choice should provide several mechanisms for doing the pure data transfer that you are asking about. Choose the one that fits your data best.