below is my code, but when i send the message thru client socket i receive Specified argument was out of the range of valid values. Parameter name: size

Can anyone help me !

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

        Dim serverStream As NetworkStream = clientSocket.GetStream()
        Dim outStream As Byte() = _

        serverStream.Write(outStream, 0, outStream.Length)

        Dim inStream(1024) As Byte
        serverStream.Read(inStream, 0, CInt(clientSocket.ReceiveBufferSize))
        Dim returndata As String = _
        msg("Data from Server : " + returndata)
    End Sub

This will fix it.

Dim inStream(clientSocket.ReceiveBufferSize) As Byte
serverStream.Read(inStream, 0, clientSocket.ReceiveBufferSize)
Dim returndata As String = System.Text.Encoding.ASCII.GetString(inStream)
commented: tq +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.