孤独不哭(苦)'s profile孤独不哭(苦)的共享空间PhotosBlogListsMore ![]() | Help |
|
|
孤独不哭(苦)的共享空间November 24 爱的伤痛雨就是雨 你就是你 雨滴回不到天上变成云 你给我美丽看数清结局 风就是风 我就是我 风总是吹走了无恨的伤痛 梦总是给人那得不到的温柔 如果爱的伤痛 能给黑暗心房开辟一扇窗门 就让我带着遗忘的泪水 飞出去潇洒地流浪 如果爱的伤痛 无法改变我对你的期盼 等待着你回心转意 让我再次爱你就像从前你爱我一样 Internet Communications Engine ---3 前面的代码都是例行公事,public class PrinterI : _PrinterDisp的代码才是我们需要的(简单吧!) 按照同样的方法,我们建立IceClientTest项目,先添加Printer.cs文件,然后编写Cient.cs文件,具体内容如下: using System;![]() namespace IceClientTest { /// <summary> /// Summary description for Client. /// </summary> public class Client { public Client() { // // TODO: Add constructor logic here // }![]() public static void Main(string[] args) { int status = 0; Ice.Communicator ic = null; try { ic = Ice.Util.initialize(ref args); Ice.ObjectPrx obj = ic.stringToProxy( "SimplePrinter:default -p 10000"); PrinterPrx printer = PrinterPrxHelper.checkedCast(obj); if (printer == null) throw new ApplicationException("Invalid proxy"); printer.printString("Hello World!"); } catch (Exception e) { Console.Error.WriteLine(e); status = 1; } finally { if (ic != null) ic.destroy(); } Environment.Exit(status); } } }![]()
我这里还有中文版的说明文档,感兴趣的朋友研究一下,交流交流-------- Internet Communications Engine ---2![]() 恭喜你,初战告捷!继续加油! 我用VS.NET建了一个空的解决方案IceTest,然后添加了一个空的项目IceTest,加入Printer.cs文件,最后建立Server.cs文件(不用说你也猜到了,现在是编写服务端)。文件目录如下: ![]() 在Server.cs中添加如下代码: using System;![]() namespace IceTest { /// <summary> /// Summary description for Server. /// </summary> public class Server { public Server() { // // TODO: Add constructor logic here // }![]() public static void Main(string[] args) { int status = 0; Ice.Communicator ic = null; try { ic = Ice.Util.initialize(ref args); Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints( "SimplePrinterAdapter", "default -p 10000"); Ice.Object obj = new PrinterI(); adapter.add( obj, Ice.Util.stringToIdentity("SimplePrinter")); adapter.activate(); ic.waitForShutdown(); } catch (Exception e) { Console.Error.WriteLine(e); status = 1; } finally { if (ic != null) ic.destroy(); } Environment.Exit(status); } }![]() public class PrinterI : _PrinterDisp { public override void printString(string s, Ice.Current current) { Console.WriteLine(s); } } }Internet Communications Engine ---1 Ice是一种优秀的分布式网络中间件,比起Corba好上许多,也更简洁。优点我在这里也不便多说了,有专文介绍,也不是今天的主题。有兴趣的可以查一下,《程序员》杂志好像有专题。 |
|
|||||
|
|