Sockets, multi-threading in .NET Applications for cooperative work [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm currently developing an application that is simillar to a simple bitmap graphics editor, like MS Paint.
The application is Windows Forms and I use different c# Graphics classes for drawing.
I wonder if there is a way to use Sockets or any other tools to make my app collaborative. I want to allow several people connect to my app and draw teamwise.
Is it possible with Windows Forms? I'd appreciate any suggestions.

At first: It doesn't matter if you use WinForms or any other template. You can easily add missing references to any type of project.
The two possible sockets would be either TCP or UDP.
A problem with these Sockets is that they are usually used for p2p connections.
Additionally only TCP guarantees the correct arrival of all sent packets, so in your case it would be highly recommended.
In this thread they discuss the problematic of many clients to one server:
TCP server with multiple Clients
If you made it to connect with multiple connections you should think of a system to handle each clients changes.
I'd propose a Server/Client system, where one person hosts the session.
Each client has a copy of the image and everytime someone changes a pixel a local event gets called that transmits the changes to the server.
The server now only has to "flush" the changes to every client connected.
One tricky thing could be two clients changing the same pixels at the same time, but thats your job =P

Related

Communicate with several ports on a server using multiple threads [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
I apologize for the multiple questions but I am having a hard time finding information on exactly what I am trying to do here.
Background:
I am working on a project that involves communicating with several server ports simultaneously that needs to somewhat scale. Some background on the project is I have a web application for users to pass commands to a console application. This console application will then send those commands to a specific port on a preexisting server through a tcp client.
My specific questions regard the console application communicating with the preexisting server.
My idea:
So my idea is to use a producer-many consumers thread scheme. I will need to be able to communicate with up to 300 different ports simultaneously and constantly through TCP connections. This console application will run as a windows service or something along those lines.
Question 1:
I am thinking of using a ConcurrentDictionary<string,ConcurrentQueue>() to track a queue of commands for every specific thread. Is there a better way to do this? I ask because I assume every thread would need access to the entire Dictionary of commands correct? Maybe this is a good approach but I have never done something like this.
Question 2:
Does spawning a single thread for each port I need to send commands to on the server make sense? The only reason I am thinking of doing this is because I will need to keep a TCP connection open for a very long time. The user can choose when to shut down the tool/connection. The only requirement really is this needs to be communicating for days at a time. The MOST I will reach is about 300 threads using this approach.
Question 3:
Obviously using an asynchronous approach is going to be necessary for this to scale well. Can anyone point me to some GOOD not out dated resources of the PROPER way to implement something like this asynchronously. I am willing to even pay for a book / online course if you have a good recommendation. The Microsoft docs are not very helpful because they do a scheme of 1 send and 1 read and then close the tcp connection.

In C#, How do I monitor what goes in and out my ip sockets that other programs are using? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Trying to make console app that monitors alongside its main program, and monitors what the main program has going in and what goes out its tcp/ip sockets. I have seen people do this in a few programs, but I can't figure out how. Something about using a raw socket, but I am not sure.
Any ideas how?
If you want the console app to be entirely separate from the main program, you can do this various ways:
Create a man-in-the-middle proxy for the connections. Run a client and server socket from your console application - i.e. clients connect to your proxy server and then your proxy server will forward the connection to your main program. This allows you to record the packets on their way through your console.
Hook winsock.dll. Essentially you will be gaining access to the parameters of send() and recv() calls that your main program makes, and you can then output or do as you like with it.
Forget programming it, and use Wireshark or another network sniffer to check what's going in or out.
More information on number 2:
It was surprisingly difficult to find good tutorials in C#, mainly because it's generally done with C++ or C. Some links to get you started:
https://en.wikipedia.org/wiki/Hooking
http://csns.calstatela.edu/download.html?fileId=2062150
http://www.elitepvpers.com/forum/co2-programming/1917917-c-dll-injecting-hooking.html
A tool to assist with hooking: http://easyhook.codeplex.com
I'll update this list as I find better resources. I might make a tutorial myself, will keep you informed.

C# RESTful Framework, not based on WCF [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'am looking for C# RESTful framework (best with json support), which is not based on WCF in any way. WCF requires me to create namespace reservations, and this is thing i'd like to avoid (i already tried Nancy). The thing is target PCs for my service are older Windows XP machines, where are registering tools missing (netsh has no http context).
Can anyone suggest me good solution?
Take a look here. it's really only an issue if you have a self hosted WCF service running along side IIS. Other then that, if you run inside IIS, you are the only thing listening to port 80, or you are listening to a different port, then you dont care about URL registration. you can also redirect the request from IIS to a different port on the same machine.
personally I really prefer WCF to all other and currently more popular alternatives, it gives you the best flexibility , and although it has a pretty significant learning curve, once you are "on top of the curve" gives you, in my opinion, the best "features developed / time invested" ratio
Excluding WCF, I think your best solution is this (as doan commented):ASP.Net Web Api combined with this (another site ) which is an open source project that microsoft pretty much adopted, and its all shown here
bare links:
http://msdn.microsoft.com/en-us/library/ms733768%28v=vs.110%29.aspx
http://www.asp.net/web-api
http://json.codeplex.com/
http://james.newtonking.com/json
http://www.asp.net/web-api/overview/formats-and-model-binding/json-and-xml-serialization

Is there a tool for monitoring bugs for WinForm systems? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
We are developing a winform CRM system that is installed over several pc's in one room (over 25 stands) and all clients in that room communicates with a single server system that we also developed, using TCP/IP. The server app is connected to an SQL DataBase.
For over 3 months now, awe are having a huge bug that causes all clients in the room to crash, and we have no idea why.
Can anyone please tell me if there is a tool for developers (even paid), that can help us monitor the clients and the server and give us some information about the cause of these crashes ?
Do proper log writing for all relevant transactions, which is free to use
One of the best for desktop applications, I found was DeskMetrics (paid) .
There are available any kind of conigurations, like: exception, custom action... logs and also ploting over them and other data.

Develop a basic DNS server (in C#) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am developing a very basic DNS server for my own purpose. The way I understand it, the DNS server receives UDP packets containing the requested domain name and returns the corresponding IP under some kind of standard form.
There is a standard library for reading/writing UDP packets from/to binary format. But where can I find a C# library for serialising/deserialising DNS requests/responses?
The open source ARSoft.Tools.Net library contains a DNS Server component (see documentation).
You could use this library directly, or just use the source as a starting point for building your own DNS request serializer.
As far as I can tell, I couldn't find a library for C# which handles DNS packet serialization/deserialization, which means it's likely you'll have to roll your own.
Edit: I came across this network packet sniffer project on Code Project which might have what you need. Claims to be able to to parse TCP/UDP/DNS
I did find this very helpful site for TCP/IP which has a pretty comprehensive set of pages describing DNS packet types including the general message format.
There might be some additional help from this previous SO question though.
If you look at wikipedia you find a list over all RFC's for the dns protocol, i find rfc's to be the best way to implement a network protocol!
now the dns protocol has rather many rfc's so i dont know if this is the best way to read up on the protocol but you get all the information you need atleast.
http://en.wikipedia.org/wiki/Domain_Name_System#Internet_standards

Categories