| | |
[HELP]sending many picture using socket programming
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2009
Posts: 46
Reputation:
Solved Threads: 1
i'm try to send many picture using socket programming in VB 2005 from client to server. but, after i run the program, only the first picture that reach destination server. and there is an error saying that my socket are no longer connected after the first picture are sent.
client side : ---> sender
at(0) -----> number of file that I want to send
at(3) n at(6) -----> file name address that I want to send
Server side : ------> receiver
arrayteks(0) -----> number of file that I want to receive
arrayteks(3) n arrayteks(6) -----> file name address where I want save the received file
many thanks before...
client side : ---> sender
at(0) -----> number of file that I want to send
at(3) n at(6) -----> file name address that I want to send
VB.NET Syntax (Toggle Plain Text)
i = 1 Dim x As Integer Dim z As Integer = 3 If at(3) <> Nothing And at(6) <> Nothing Then x = at(0) + 1 For var = i To x Dim PACKET_SIZE As UInt16 = 4096 Dim ByteArray() As Byte ' Data buffer Dim filestream As FileStream = New FileStream(at(z), FileMode.Open, FileAccess.Read) Dim Reader As New BinaryReader(filestream) Dim Writer As New BinaryWriter(clientSocke.GetStream) ' Get socket's stream 'send size of file Writer.Write(CInt(filestream.Length)) 'Send the file data Do 'read data from file ByteArray = Reader.ReadBytes(PACKET_SIZE) 'write data to Network Stream Writer.Write(ByteArray) Loop While ByteArray.Length = PACKET_SIZE 'make sure all data is sent Writer.Flush() z = z + 3 Writer.Close() Reader.Close() Next end if
Server side : ------> receiver
arrayteks(0) -----> number of file that I want to receive
arrayteks(3) n arrayteks(6) -----> file name address where I want save the received file
VB.NET Syntax (Toggle Plain Text)
Dim x As Integer Dim z As Integer = 3 If arrayTeks(3) <> Nothing And arrayTeks(6) <> Nothing Then x = arrayTeks(0) + 1 For var = i To x Dim PACKET_SIZE As UInt16 = 4096 Dim Reader As BinaryReader Dim ReadBuffer(PACKET_SIZE - 1) As Byte Dim NData As Int32 Dim MStream As MemoryStream Dim LData As Int32 Reader = New BinaryReader(clientSocket.GetStream) ' Read Length of data (Int32) NData = Reader.ReadInt32 ' Now comes the data, save it in a memory stream MStream = New MemoryStream While NData > 0 LData = clientSocket.GetStream.Read(ReadBuffer, 0, PACKET_SIZE) MStream.Write(ReadBuffer, 0, LData) NData -= LData End While SaveFile(arrayTeks(z), MStream.ToArray, False) 'Then z = z + 3 Next end if
many thanks before...
![]() |
Similar Threads
- Socket Programming... (C#)
- [socket programming] send picture with socket programming (VB.NET)
- About socket programming in php (PHP)
- Socket Programming (ASP.NET)
- C++ socket programming (C++)
- Socket programming + porting Unix to Win32 (C)
Other Threads in the VB.NET Forum
- Previous Thread: update database when the website is nor running on the browser
- Next Thread: INSERTING RECORD IN THE DATABASE(sURNAME AND TEMPLATE)
Views: 486 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access application arithmetic array assignment basic binary bing box button buttons c# center code combobox component connectionstring convert data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dll dosconsolevb.net error excel file-dialog firewall folder google hardcopy highlighting image images isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project record reports" save savedialog serial server sorting sql string studio syntax temp text textbox timer toolbox updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





