从客户端向服务器发送序列化对象

时间:2010-08-10 09:01:10

标签: vb.net

我正在尝试将一个Arraylist发送到我的服务器以向所有其他客户端广播,但我不确定在序列化之后,我该如何继续发送。这就是我在这里:

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        Dim BinFormatter As New Binary.BinaryFormatter()
        Dim FS As New System.IO.FileStream("c:\test.txt", IO.FileMode.Create)

        Dim i As Integer
        Dim f As Integer
        Dim listchkBox As New ArrayList()
        For Each ctrl As Control In Me.Controls
            Dim chkbox As CheckBox
            If TypeOf ctrl Is CheckBox Then
                i += 1
                chkbox = ctrl
                If chkbox.Checked = True Then
                    listchkBox.Add(i)
                End If
            End If
        Next
        For f = 0 To listchkBox.Count - 1
            MsgBox(listchkBox.Item(f))
        Next

        BinFormatter.Serialize(FS, listchkBox)

       ' I am not sure if I am doing right after this 
       ' line I am not sure how to pack it into a stream and 
       ' send across, please advice...

End Sub

谢谢!

1 个答案:

答案 0 :(得分:0)

你应该看看Remoting或WCF。

快速搜索Stackoverflow给出了这个,这应该给出一个如何使用它的基本概念:

.NET Remoting HelloWorld