The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
'Here is the Client Code Private Sub SendInfoFile() Dim fileBuffer As Byte() Dim fileStream As Stream Dim fback As String fback = "C:\text1.txt" fileStream = File.OpenRead(fback) 'open file to read ReDim fileBuffer(fileStream.Length) ' set size of file fileStream.Read(fileBuffer, 0, fileStream.Length) ' read the file in Dim clientSocket As New TcpClient(IPAddy, 667) 'send back on port 667 to Ip address of client in Global IPaddy Dim netWorkStream As NetworkStream netWorkStream = clientSocket.GetStream() netWorkStream.Write(fileBuffer, 0, fileStream.Length) netWorkStream.Close() End Sub 'And here is the code for the Server to Catch and write the file. Public Sub handlerThread() Dim handlerSocket As Socket handlerSocket = alSockets(alSockets.Count - 1) Dim networkStream As NetworkStream = New NetworkStream(handlerSocket) Dim blockSize As Int16 = 1024 Dim thisRead As Int16 Dim dataByte(blockSize) As Byte SyncLock Me Dim fileStream As Stream fileStream = File.OpenWrite("C:\copiedtext.txt") While (True) thisRead = networkStream.Read(dataByte, 0, blockSize) If thisRead = 0 Then Exit While End If fileStream.Write(dataByte, 0, dataByte.Length) End While fileStream.Close() End SyncLock lbxConnections.Items.Add("File Written") handlerSocket = Nothing End Sub
Join the community of 500,000 technology professionals and ask your questions.