高分求用C#做客户端,C++做服务端的网络编程实例(求源码) 公司要小弟近日用C#搞个网络客户端,可是兄弟我还没接触过网络编程。工期又紧,在不出东西有失业危险呀。恳请网上的朋友帮忙。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我和你现在的处境是一样的但我做的这个还有点问题,不过你可以参考一下。public static byte[] serialzable() { byte []length=new byte[12]; _Head head=new _Head(100,1000,800); IFormatter iformat=new BinaryFormatter(); Stream stream=new MemoryStream(length); iformat.Serialize(stream,head); BinaryReader br=new BinaryReader(stream); return br.ReadBytes(length.Length); } [Serializable] public struct _Head { public int Cmd_ID; public int Pk_Length; public int Status; public _Head(int Cmd_ID,int Pk_Length,int Status) { this.Cmd_ID=Cmd_ID; this.Pk_Length=Pk_Length; this.Status=Status; } } C++写的服务端已经被别人写好了,还有数据的格式、加密等需要调用一个C++做的DLL中的函数。而这个DLL中的函数大多都是用的char* uchar*这样的参数输出值。用两个主要问题:1、在C#代码中如何得到这个DLL函数中char* uchar*的输出结果(如:C++中的函数如此写 extern BZEX_API void ZLongTime(unsigned long ctime, char *buf);C#中引用 [DllImport("bzex.dll",EntryPoint="?ZLongTime@@YAXKPAD@Z", SetLastError=true, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)] static extern unsafe void ZLongTime(ulong ctime,这里该是什么参数);)C#代码如何得到ZLongTime的输入,得到的输出是什么C#格式。) 上面C#代码如何得到ZLongTime的输入,得到的输出是什么C#格式。)应该是C#代码如何得到ZLongTime的输出,得到的输出是什么C#格式。) 据公司使用delphi做客户端的兄弟说 ZLongTime函数输出的最终结果应该是“字符串”。我在C#中如何得到这个“字符串”? char* 其实就是 byte[]需要先string to byte[],有很多例子,参考一下 试一下 1 static extern unsafe void ZLongTime(ulong ctime,这里该是什么参数);传入byte[]的引用或char[]的引用 (ref关键字)2 ZLongTime 的格式,问DLL开发人员,ulong ctime 看名字像是完整的日期格式,精确到秒的.自己试吧,先考虑英文系统的默认格式 类里如何调用窗口控件? vs2003 datagrid复杂报表,100分求教 c#中一个小问题,关于sort(Compare)的问题 解答几个简单的问题,是关于链接库跟系统事件的 如何解决水晶报表用Export导出PDF时出现"登录错误" 如何做短信的接收和发送? 征求一个C/S的C#的人事管理系统加毕业论文,分数还可以加的, 请教:使用CheckedListBox控件时,怎样一次删除多项被打钩的项。。。。。 恭喜思归和TheAres,顺便我的遗憾(散分!!!!!!) IIS问题 求教 正则表达式全角问题 请教ListView的问题
{
byte []length=new byte[12];
_Head head=new _Head(100,1000,800);
IFormatter iformat=new BinaryFormatter();
Stream stream=new MemoryStream(length);
iformat.Serialize(stream,head); BinaryReader br=new BinaryReader(stream);
return br.ReadBytes(length.Length);
}
[Serializable]
public struct _Head
{
public int Cmd_ID;
public int Pk_Length;
public int Status;
public _Head(int Cmd_ID,int Pk_Length,int Status)
{
this.Cmd_ID=Cmd_ID;
this.Pk_Length=Pk_Length;
this.Status=Status;
}
}
(如:C++中的函数如此写 extern BZEX_API void ZLongTime(unsigned long ctime, char *buf);C#中引用 [DllImport("bzex.dll",EntryPoint="?ZLongTime@@YAXKPAD@Z", SetLastError=true, CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
static extern unsafe void ZLongTime(ulong ctime,这里该是什么参数);)C#代码如何得到ZLongTime的输入,得到的输出是什么C#格式。)
char* 其实就是 byte[]需要先string to byte[],有很多例子,参考一下
1 static extern unsafe void ZLongTime(ulong ctime,这里该是什么参数);
传入byte[]的引用或char[]的引用 (ref关键字)2 ZLongTime 的格式,问DLL开发人员,ulong ctime 看名字像是完整的日期格式,精确到秒的.自己试吧,先考虑英文系统的默认格式