|
-
Jul 21st, 2009, 06:52 AM
#1
Thread Starter
Hyperactive Member
Winsock File Transfer [Unresolved]
I made a multi-user chat program in VB.Net using the WinSock 6.0 control.
I now need to be able to transfer pictures from client to server and view them on the server. I do this by converting the Image to a Base64String, then send the string over the WinSock TCP connection.
However, a single packet cannot nearly handle the entire picture. Data is cut off after about 4337 characters, and the entire picture is usually at least 250,000 characters.
I made this function that sends file text over winsock, packet by packet.
Code:
Public Sub SendFileText(ByVal text As String, Optional ByVal interval As Integer = 3000)
Dim cPack As String = ""
If text.Length < interval Then
Sock.SendData("SS|" & text)
Else
Do Until text = ""
cPack = text.Substring(0, interval)
Sock.SendData("SS|" & cPack)
text = text.Substring(interval)
Loop
End If
End Sub
I was hoping this would send the file text in parts, so i could then append them on the Server side and rebuild a file.
However, this code behaves the same way as sending the entire file at once does.
I've also noticed that when you try to send multiple packets quickly over a winsock connection that they append to each other, which could explain why this approach isnt working.
Is there any way i can transfer a picture from client to server?
Thanks,
Philly0494
Last edited by Philly0494; Jul 22nd, 2009 at 09:25 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|