??xml version="1.0" encoding="utf-8" standalone="yes"?>
1.Project Settings >> C/C++(Tab) >> Category:Code Generation >> User run-time library:Debug Multithreaded DLL
2.Project Settings >> C/C++(Tab) >> Category:Preprocessor >> Additional include directories:(在此中填入一个点".",表示根目?
3.Project Settings >> C/C++(Tab) >> Category:C++ Language >> N?Enable Run-Time Type Information(RTTI)"?br />
4.Project Settings >> Link(Tab) >> Category:General>>?Object/library modules:"框中的未首加入两个包"iced.lib"?iceutild.lib"
q样,整个ICE工程的DEBUG版本徏立完成了.
以上Ҏ?VC++6.0 SP6 ?ICE3.0.0 下通过
?q是由于我的LINUX下不支持中文?是注释不用管?br />Demo.cpp:代码如下:
#include <string.h>
#include <iostream>
#include "Demo.h"
int main( int argc , char* argv[])
{
MemoryInf mymem;
DiskInf mydisk;
DbInf mydb;
Inital( argv[1]);
mydisk = GetDiskStat();
mymem = GetMemInf();
mydb = GetDbStat();
printf("disk total space:%d\n",mydisk.TotalSpace);
printf("disk FreeSpace space:%d\n",mydisk.FreeSpace);
printf("Memory TotalMem:%d\n",mymem.TotalMem);
printf("ValidMem:%d\n",mymem.ValidMem);
printf("VirtualMem:%d\n",mymem.VirtualMem);
printf("DbConnNum:%d\n",mydb.DbConnNum);
printf("DbStat:%d\n",mydb.DbStat);
printf("cpu:%d\n",GetCpuInf());
DesIceCom();
return 1;
}
5.~译文g生成可执行程?
用以下命?
$c++ -lMyApp -o Demo Demo.cpp
说明:-lMyApp参数表示,用动态链接库libMyApp.so一赯行编?对了libMyApp.so最好放?usr/lib目录下哈
如不出意外刚会生成名为Demo的可执行文g
char 转换?string ?BR> char* str = "char 转换?string ?;
SendData.strSql = str;
//SendData.strSql 为std::string?/P>
以下是中文文中关于端点的描q?
D.2 端点
U要
endpoint : endpoint
描述
端点列表׃个或多个用冒?:) 分隔的端点组成。端点的格式如下所
C: protocol option。所支持的协议有tcp、udp、sslQ以?BR>default。如果用了defaultQ它会被Ice.Default.Protocol 属性的值替
代。如果端点的格式有问题,或者指定了未知的协议,应用会收?BR>Ice::EndpointParseException?BR>只有安装了IceSSL 插gQ才能用ssl 协议?BR>各个协议及其所支持的选项在下面描述?BR>TCP 端点
U要
tcp -h host -p port -t timeout -z
描述
tcp 端点支持以下选项Q?BR>选项描述客户语义服务器语?BR>-h host 指定端点的主机名
或IP 地址。如?BR>没有指定Q将使用
Ice.Default.Hos
t 的倹{?BR>定要连接到的主
机名或IP 地址?BR>定对象适配器用
于侦听连接的|络
接口Q以及在适配
器所创徏的代理中
向外公布的主?BR>名?BR>-p port 指定端点的端?BR>受?BR>定要连接到的端
? 必须指定)?BR>如果没有指定q个
选项Q或是port ?BR>Ӟ端口由操作
pȝ选择?BR>932 代理与端?/P>
以上是基于TCP协议?关于UDP,SSL协议的也差不?BR>
我在我的聊天E序中连接LAN中一台服务器的代?
#include <Ice/Ice.h>
#include <Printer.h>
using namespace std;
using namespace Demo;
int main(int argc, char * argv[])
{
int status = 0;
char strtemp[100];//聊天内容
char clientname[20];//客户?BR> char chattmp[130];
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
/*q接服务?SimplePrinter16所甌的代理ID,default即ؓ使用默认的协议TCP,-h 192.168.1.16 为服务端所在LAN中的IP地址,-p 9600为端口号*/
Ice::ObjectPrx base = ic->stringToProxy("SimplePrinter16:default -h 192.168.1.16 -p 9600");
//创徏一个Printer的代?Printer即ؓ客户端与服务器端的接?Q利用checkedCast(base)查代理是否存?BR> PrinterPrx printer = PrinterPrx::checkedCast(base);
if (!printer)
{
throw "Invalid proxy";//代理不存?BR> }
else
{
printf("误入您的ID:");
cin >> clientname;
}
while ( 1 )
{
cin >> strtemp;//输入聊天内容
if ( strcmp( strtemp,"q") == 0 )
{
break;//退?BR> }
//strcat( chattmp, clientname );
strcpy( chattmp, clientname );
strcat( chattmp, " say: " );
strcat( chattmp, strtemp );
printer->printString(chattmp);
}
//发给服务器的退出消?BR> printer->printString(clientname);
printer->printString("已退?");
cout << "成功退?" << endl;
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}
if (ic) {
try {
ic->destroy();
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
}
}
return status;
}