公司要小弟近日用C#搞个网络客户端,可是兄弟我还没接触过网络编程。工期又紧,在不出东西有失业危险呀。恳请网上的朋友帮忙。

解决方案 »

  1.   

    我和你现在的处境是一样的但我做的这个还有点问题,不过你可以参考一下。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;
    }
    }
      

  2.   

    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#格式。)
      

  3.   

    上面C#代码如何得到ZLongTime的输入,得到的输出是什么C#格式。)应该是C#代码如何得到ZLongTime的输出,得到的输出是什么C#格式。)
      

  4.   

    据公司使用delphi做客户端的兄弟说 ZLongTime函数输出的最终结果应该是“字符串”。我在C#中如何得到这个“字符串”?
      

  5.   


    char* 其实就是 byte[]需要先string to byte[],有很多例子,参考一下
      

  6.   

    试一下 
    1 static extern unsafe void ZLongTime(ulong ctime,这里该是什么参数);
    传入byte[]的引用或char[]的引用 (ref关键字)2 ZLongTime 的格式,问DLL开发人员,ulong ctime 看名字像是完整的日期格式,精确到秒的.自己试吧,先考虑英文系统的默认格式