Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm designing a program that uses a third party electrical solver.
I want to perform monte carlo simulations on large electrical grids and most of the times the program (mine) takes hours.
Because of this I thought that if I create a client in other computer I could call from my computer (and vice versa) I would have a nice distributed simulator.
Since I lack the knowlwdge, I would like to know what is the best way (if even possible) to "invoque" a program installed in another computer in the local network to do a specific task: simulate a file that I send and return the results back. The idea is to call the solver in lets say 10 computers at a time and gather the results asynchronically.
The language I use is C#.
I hope that my question is clear enough.
The easiest is to have a shared drive on the network, to which all computers have access. Then your app saves the input file (or one input file per machine, depends how you want to do it) on the shared drive, and your app starts another app remotely on each client. It monitors each one it starts for the exit status. After all of them have exited, it takes the output files and combines them and processes the data. Job done. The simplest "remote process" invocation is probably through psexec which you can download from technet, we have used it very successfully and very simple to use. The top two answers of How to execute process on remote machine, in C# have other good ideas: I think you will find them more overhead (longer to implement) but will give you more power in the long run.
Related
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.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to share data between programs that run locally which uses different languages, I don't know how to approach this.
For example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it?
I thought about using sockets for this but I'm not sure that this is the right approach, I also thought about saving the data in a file, then reading the file from the other program, but, it might even be worse than using sockets.
Note that I need to share strings almost a thousand times between the programs
There are a lot of ways to do so, I would recommend you reading more about IPC (Inter Process Communication) - sockets, pipes, named pipes, shared memory and etc...
Each method has it's own advantages, therefore, you need to think about what you're trying to achieve and choose the method that fits you the best.
Any kind of IPC (InterProcess Communication) — sockets or shared memory. Any common format — plain text files or structured, JSON, e.g. Or a database.
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.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm refactoring an application used by the employees of an insurance carrier, they have had some problems with some kind of malware on their computers that was controlling this application to do bad things, or at least that's what they say.
I'm pretty sure the malware is using the Win API to make calls to the application instance, so my question is, there's any way to detect if a real user is controlling the application or it's being controlled by another process through calls to the Win API? The app is coded in C#.
This answer is coming from my experience with developing Win32 apps using C++.
I can only think of two ways in which the app is being controlled -- one using OLE automation, using automation verbs and secondly inserting keyboard/mouse events into the system event queue. (I'm assuming that this app is not listening for any network originated commands). You can verify the first by checking the source code and using a debugger with some OutputDebugString calls. The second can only be detected by a malware scanner. Any COTS/free AV or MS security essentials should be able to identify a malware, unless of course it's written internally by a malicious employee.
Have you taken a look at the task manager process list and gone through them one-by-one to see if there's anything that looks suspicious? Can you run the app with elevated privileges? Then the OLE automation client, if one is present, won't be able to access the process.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Running java in batch would look like this
#ECHO OFF
java -Xmx512m -Xms512m -jar "PROGRAM.jar"
PAUSE
that would give it 512mb of ram. How could I do that in C#?
The compiled .exe file from c# has a header, which can be executed by the windows shell, with double click, as how you would start Java in command line, but the command line it would be saved into a bat file. It is very different from a native, win32 exe. It needs a Java like virtual machine, just the runtime compilation is different.
There are many options how to give launch and runtime parameters, one of is the config file. Please take a look Here.
Use Windows Job Objects API.
Jobs can limit memory usage and process priority.
There are 2 interpretations of your question as currently written:
1 - If you need to call a C# application from the command line / batch file just
Generate an EXE (such as a Console Application)
Call it directly by its filename (for example C:\MyApp\MyApp.exe)
2 - Limiting the amount of memory a certain program may consume is a bad idea.
Make sure your application only consumes the neccesary memory by writing good code.
I'm not aware of a mechanism that will limit the amount of memory a given .Net application can consume. And if it were such a thing, it's still a bad idea. Whenever the application reached that limit it would simply crash with an OutOfMemoryException.