I'm working with asp.net MVC. Now I don't know how to send data form a server (using asp.net ) to another server using (win32 console command line). Plz help me.
P/S: Is there any security hole in this method.
I'm working with asp.net MVC. Now I don't know how to send data form a server (using asp.net ) to another server using (win32 console command line). Plz help me.
P/S: Is there any security hole in this method.
You have two servers trying to communicate. If you are going to use IP (I am assuming you will since you mentioned Winsock) you must choose between these two protocols:
Once you've decided which one to use, you can write a server process (the console application) that listen to a specific port (TCP or UDP port depending on what you've chosen) that will serve your client process (the ASP.NET application).
If you use TCP/IP, you use sockets to communicate. If you use UDP/IP, you will send and receive independent packets.
Here is a TCP/IP client/server code sample in C# you can use. You will wrap and run the client portion of this example is a class you can access within ASP.NET MVC.
Here is a UDP/IP server code sample in C#.
Regarding your question of the security of this approach, the question does not provide enough information to answer it properly. You will need to provide more information.
Well generally the case is that most ports today are blocked behind firewalls so setting something like that up with winsock, is outdated. If you are tring to connect two servers there are many options, You could look into the System.Web.WebClient,System.Net.HttpWebRequest,Microsoft's Sync Framework, Rhino queues but heres the run down on the first two.
In short, HttpWebRequest gives you more fine grained control over your request. WebClient does not. It encapsulates most of the stuff for you.
WebClient is very useful if you want to do specialized, one-off tasks, eg: download file, do forms post etc.
HttpWebRequest is useful if you want to do more complicated stuff.
The WebClient is especically simplified, we can use it's DownloadData, DownLoadFile to retreive file/stream from remote webserver. Here are some tech articles and resources describing using webclient or webrequest:
Hosting WCF services, WebClient here and webrequest here.