程序如下:<VB.NET 2003>
定义结构
    Public Structure strHEAD
        Public Size As Integer     '数据包的长度
        Public CmdID As Integer    '命令码
       End Structure       Public Structure strPACKAGE
        Public Head As strHEAD                             '
数据包的包头
        <VBFixedArray(nCMPP_PKG_SIZE)> Public Data() As Byte
'要发送的数据
            End Structure            Public Structure strCONNECT
        <VBFixedArray(6)> Public UserID() As Byte        <VBFixedArray(16)> Public Authenticator() As Byte        Public Ver As Byte      End Structure程序:
Public Function Login_R(ByVal UserNo As String, ByVal Password As
String) As Integer
        Dim pkg As New strPACKAGE
        Dim msg As New strCONNECT
        Dim nsize, i As Integer
        Dim strtimes() As Byte
        Dim strtemp As String
        Dim err As Integer        ReDim pkg.Data(400)      '表示定长数组
        ReDim msg.UserID(6)
        ReDim msg.Authenticator(16)
        ReDim strtimes(20)        Try
            nsize = Len(pkg.Head) + Len(msg)          '消息格式头
            pkg.Head.Size = nsize
            pkg.Head.CmdID = 1 '命令            Dim EncodingUTF As Encoding = System.Text.Encoding.ASCII            msg.SPID = EncodingUTF.GetBytes(UserNo)
            strtemp = Format(Now, "MMddHHmmss")
            strtimes = EncodingUTF.GetBytes(strtemp)
            msg.Authenticator = EncodingUTF.GetBytes(MD5(UserNo &
"000000000" & Password & strtemp))
            msg.Ver = 1
            msg.Timestamp = CInt(strtemp)
疑点:
我现在要把  pkg.data= msg 的数据
然后 通过 Socket
假如 socket 已经建立 connect
Socket.send (pkg的数据,nsize)
这两步应该怎么实现? 静候您的答案谢谢!        Catch ex As Exception
            '错误
        End Try    End Function