| Sign In/My Account | View Cart |
| Article: |
Using Network Streams | |
| Subject: | Re:Large Files | |
| Date: | 2006-10-26 11:31:32 | |
| From: | vaibe | |
|
Response to: Large Files
|
||
|
hello there... just combine few concepts of network streams and you will be able to send larger files also(like .bmp,.jpeg etc..) server(receiving only) ----------------------- Const portNo As Integer = 500 Const BUFFER_SIZE As Integer = 10 Dim localAdd As System.Net.IPAddress = IPAddress.Parse("127.0.0.1") Dim listener As New TcpListener(localAdd, portNo) listener.Start() Dim tcpClient As TcpClient = listener.AcceptTcpClient() Dim NWStream As NetworkStream = tcpClient.GetStream Dim bytesToRead(tcpClient.ReceiveBufferSize) As Byte Dim numBytesRead, j As Integer '---read incoming stream and writing the bytes to file Const FILE_NAME = "d:\image_copy.bmp" Dim fs As System.IO.FileStream fs = New FileStream(FILE_NAME, FileMode.CreateNew, FileAccess.Write) Do numBytesRead = NWStream.Read(bytesToRead, 0, BUFFER_SIZE) fs.Write(bytesToRead, 0, numBytesRead) Loop Until Not NWStream.DataAvailable fs.Close() tcpClient.Close() listener.Stop() MsgBox("received")
|
||