¿Cómo se transferiría el archivo a través de Socket en vb.net y WCF?

I want to transfer the file through socket in vb.net using Socket .

preguntado el 03 de mayo de 12 a las 07:05

Tu pregunta no tiene sentido. -

Great idea. Now, did you try to search any existing responses already? -

That's nice to know - now do you have a question? -

1 Respuestas

lado del servidor:

Do
    Try
        message = reader.ReadString()

        If message = "ATTACHMENT" Then
            writer.Write("")
            Dim num = reader.ReadInt64
            Dim BR As BinaryReader
            Dim FS As NetworkStream
            FS = output
            Dim fulname As String = reader.ReadString
            BR = New BinaryReader(FS)
            Dim buffer(num) As Byte
            buffer = BR.ReadBytes(num)

            Dim BW As BinaryWriter
            Dim FSOut As FileStream
            FSOut = New FileStream(fulname, FileMode.Create, FileAccess.Write)
            BW = New BinaryWriter(FSOut)
            BW.Write(buffer)
            message = ""
            BW.Close()
            writer.Write("CLIENT >> ATTACHMENT RECIEVED")
        End If

    Catch ex As Exception
        System.Environment.Exit(System.Environment.ExitCode)
    End Try
Loop While message <> "SERVER >> EXIT"  

Lado del cliente:

Do
    Try
        messageRecieved = reader.ReadString()

        If messageRecieved = "ATTACHMENT" Then
            writer.Write("")
            Dim num = reader.ReadInt64
            Dim BR As BinaryReader
            Dim FS As NetworkStream
            FS = socketStream
            Dim fulname As String = reader.ReadString
            BR = New BinaryReader(FS)
            Dim buffer(num) As Byte
            buffer = BR.ReadBytes(num)

            Dim BW As BinaryWriter
            Dim FSOut As FileStream
            FSOut = New FileStream(fulname, FileMode.Create, FileAccess.Write)
            BW = New BinaryWriter(FSOut)
            BW.Write(buffer)
            messageRecieved = ""
            BW.Close()
            writer.Write("SERVER >> ATTACHMENT RECIEVED")
        End If
    Catch ex As Exception
        Exit Do
    End Try
Loop While messageRecieved <> "CLIENT >> EXIT" And connection.Connected

contestado el 03 de mayo de 12 a las 09:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.