Remoting (1) -- use Reomoting to implement information delivery

Source: Internet
Author: User

Remoting?

TIPS:

1. easily construct large-scale distributed applications

2. Fast Tcp channel Remoting

3. Although it is a terminal, it is very close to the local objects used

4. Maintain the metadata of objects.

5. There is no application restriction. It can be used to control terminal objects such as login, winform, iis, and windows Server.

Missing points:

1. The application of non-standard compaction is subject to the limit of flattening.

2. When using iis, you must have your own security mechanism.

RemotingThree steps

1. Upload upload process object: This object must upload albyrefobject

2. Create a "host" program and accept the customer's requirements. Request: Singleton (SingleCall)

3. The producer uses the producer client to use the producer client: the producer client channel, and the root response URL gets the proxy.

RemotingDevelopment example(UseReomotingInformation Delivery Function)

1. Create a case similar to the following: RemoteObject ﹕

Public class RemoteObject: MarshalByRefObject
{
Public RemoteObject (){}
Public static void Bullet (String str)
{
MessageBox. Show (str, "Remoting Message", MessageBoxButtons. OK );
}
}

Only the directly or indirectly accepted albyrefobject class can be activated by the program.

2. Create a WinForm server program proposal case to accept the request for using the ticket.

A. Perform relational configuration and change Form1 to frmServer.

B. Click here to add a new application program for App. Config. The file is in a standard XML file format and is written to the following code ﹕

<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. runtime. remoting>
<Application name = "RemoteServer">
<Service>
<Activated type = "RemoteObject. RemoteObject, RemoteObject"/>
</Service>
<Channels>
<Channel ref = "tcp server" port = "8080"/>
</Channels>
</Application>
</System. runtime. remoting>
</Configuration>

C. Reference The namespace in frmServer

Using System. Runtime. Remoting;

Add the following sentence to the construction method ﹕

RemotingConfiguration. Configure ("RemoteServer.exe. config", false );

3. Create a WinForm client program example and use the program object

A. Perform relational configuration and change Form1 to frmClient.

B. Drag a label into the toolbox, change text encoding to Enter Message, Set Name encoding to lblMessage, drag a textbox, Set name To tbxMessage, and then drag buttons, set name To btnSend, text to Send

C. Click here to add an application group to apply App. Config. Configure to the following code ﹕

<? Xml version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. runtime. remoting>
<Application name = "RemoteClient">
<Client url = "tcp: // localhost: 8080/RemoteServer">
<Activated type = "RemoteObject. RemoteObject, RemoteObject"/>
</Client>
<Channels>
<Channel ref = "tcp client"/>
</Channels>
</Application>
</System. runtime. remoting>
</Configuration>

D. Fill in the blank part of the window, which is used in the Load operation. The entire generation is as follows ﹕

Private void frmClient_Load (object sender, EventArgs e)
{
// Listen the Client request, config the client infomation
RemotingConfiguration. Configure ("RemoteClient.exe. config", false );
}

Private void btnSend_Click (object sender, EventArgs e)
{
RemoteObject. RemoteObject. Bullet (this. tbxMessage. Text );
}

 

4. In fact, it should not be a step. If you attempt to commit the above cases at this time, the client will certainly commit the case. The reason is very simple: the reference is missing. No, this step is to add the upload process reference to the image type on the client and server.

5. Compile the entire solution. Run the server-side example first, then run the client-side example, and input the text in the textbox of the window body. the MessageBox of the text you typed. Too many OK.

6. This Remoting Source is now available! (Note: I am also a beginner Remoting. I welcome to discuss this article. QQ: 52433739). This article describes LoveCherry's <step by step Remoting>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.