ciao, grazie per la risposta, la mia situazione č questa, sto passando da un pc(server e uno client) un file xml da 180K, il codice che sto usando ( prendendo spunto dalla guida) č questo:
Sender file:
codice:
Private Sub FileThread()
        Dim PercorsoPrivato As String = PercorsoFileTX
        Dim IpPrivatoDestrinatario As String = IpDestinatarioFile
        Thread.Sleep(Rnd() * 10)
        Dim pingResult As Boolean = False
        Try
            pingResult = My.Computer.Network.Ping(IpPrivatoDestrinatario)
        Catch
            pingResult = False
        End Try
        Dim Reader As New IO.FileStream("c:\Sched_Termo.sch", FileMode.Open)
        Dim Sizez As Int64 = FileLen("c:\Sched_Termo.sch")
        If pingResult = True Then
            Try
                Dim Client As New TcpClient(IpPrivatoDestrinatario, 8003)
                'Dim Writer As New StreamWriter(Client.GetStream())
                Dim NetFile As NetworkStream
                NetFile = Client.GetStream
                If Client.Connected = True Then
                    Dim ByteFile(4096) As Byte
                    If Sizez > 4096 Then
                        For Block As Int64 = 0 To Sizez Step 4096
                            If Sizez - Block >= 4096 Then
                                Reader.Read(ByteFile, 0, 4096)
                            Else
                                Reader.Read(ByteFile, 0, Sizez - Block)
                            End If
                            NetFile.Write(ByteFile, 0, 4096)
                            Thread.Sleep(10)
                        Next
                    End If
                End If
                'Reader.Close()
                NetFile.Write(ASCIIEncoding.ASCII.GetBytes("END"), 0, 3)
                Client.Close()
                pingResult = pingResult
            Catch ex As Exception

            End Try
        End If
        Reader.Close()
    End Sub
il ricevente č questo :
codice:
Public Sub LeggidatiFile()                       'SOCKET 8003
        Dim netstream As NetworkStream = SocketFile.GetStream

        Dim Stream As New IO.FileStream("c:\p1.sch", IO.FileMode.Create)
        Dim Indice As Int64 = 0
        If SocketFile.Connected Then
            Do While SocketFile.Available
                Dim bytes(4096) As Byte
                Dim Msg As String = ASCII.GetString(bytes)
                If Msg.Contains("END") Then
                    Exit Do
                End If
                netstream.Read(bytes, 0, 4096)
                Stream.Write(bytes, 0, 4096)
                Indice += 4096
                Thread.Sleep(9)
            Loop
            SocketFile.Close()
        End If
        Stream.Close()
        Messaggio = Messaggio
    End Sub
con il mio codice ricevo il file ma č inspiegapilmente piu grosso dell'originale e il "END" viene scritto su file e non viso dalla funzione : Dim Msg As String = ASCII.GetString(bytes).
mettendo lo sleep sulla funzione ricevente ricevo 180K, senza si blocca a 4k. il motivo, secondo me, č che il socket diventa non disponibile dopo il primo blocco.
se hai qualche idea su come migliorare il mio codice dimmi pure, sto sclerando da questa mattina spero di esserti d'aiuto anche per il tuo problema