Click to See Complete Forum and Search --> : VB - How to send a file using the Winsock control
CVMichael
Dec 21st, 2005, 11:23 AM
I made 2 projects: ClientSend and ServerReceive
You can send files of ANY size with this (well actually any file less than 2GB).
First start the Server program, click on the "Start Listening for Connections" button.
Then start the client, choose a file you want to transfer, then click on "Send File"
The server supports multiple connections, so you can open more than one Client application and transfer more than one file.
Both of them show the progress of the transfer.
The server saves the files in its App.Path directory.
I tried to make it as simple as possible, and I did not put any comments.
I have a few comments, but that's because I copied and pasted some code from my other applications.
Anyways... enjoy... and I hope you learn something from it.
DrGonzo
Nov 1st, 2006, 06:46 AM
Hi, the speed seems to be limited to 256 KB/s. How could we increase the speed??
CVMichael
Nov 1st, 2006, 07:04 AM
Try increasing the packet size in the client, the first line in the form:
Private Const PacketSize As Long = 1024 * 4
That is 4K per packet, make it 8 or 16 (or even more)
By the way, you have an internet connection that is THAT fast ? must be a T1 or something... I wish I had my internet that fast...
BrendanDavis
Nov 1st, 2006, 07:36 AM
Try increasing the packet size in the client, the first line in the form:
Private Const PacketSize As Long = 1024 * 4
That is 4K per packet, make it 8 or 16 (or even more)
By the way, you have an internet connection that is THAT fast ? must be a T1 or something... I wish I had my internet that fast...
I have a cable modem and I've uploaded as fast as 500+ kb/s, downloaded as fast as 1.5+ mb/s. It's not that uncommon, as far as I know.
CVMichael
Nov 1st, 2006, 08:03 AM
Yea, I have cable modem too but it's 128 KBits / second Upload and 1 MBit/second download.
If you notice the values are in Bits, so you have to divide by 8 to get Bytes...
So really it's 16 KBytes/second upload, and 128KBytes/second download.
My program shows the speed in KBytes / second...
DrGonzo
Nov 1st, 2006, 08:08 AM
You have 1 Mbit/s. 256KB/s is just the double of yours...
Yeah, thats right. Today almost everyone in a "1st-world country" :cry: has got at least DSL.
Actually i have unfortunately just 384 kbit/s (48 KB/s) because my (DS)-Line is much too long (over 50 db). That really isn't fast.
I reached the 256 KB/s on my local Computer.
Watch it yourself:
http://img244.imageshack.us/img244/3195/unbenanntut0.th.jpg (http://img244.imageshack.us/my.php?image=unbenanntut0.jpg)
CVMichael
Nov 1st, 2006, 08:18 AM
That is KBytes/Second, so you reached 1984 KBytes / second that is 31,744 KBits / second !!!!
The program shows the speed in KBytes / second !
You divided KBytes by 8, but it already shows in KBytes...
CVMichael
Nov 1st, 2006, 08:25 AM
And by the way, about this:
Private Const PacketSize As Long = 1024 * 31
You are wondering why you cannot multiply by 32 ?
That's because 1024 is taken as Integer by the compiler, and 32 is also an integer, so if you multiply them together you also get integer type, but you get an overflow error, right ?
The solution is simple, comvert the numbers to Long type, like this:
Private Const PacketSize As Long = 1024& * 64& ' 64 KBytes buffer
Or if you just type in the total number (multiplied), then it will automatically convert it to long type
Private Const PacketSize As Long = 65536 ' 64 KBytes buffer
DrGonzo
Nov 1st, 2006, 08:31 AM
That is KBytes/Second, so you reached 1984 KBytes / second that is 31,744 KBits / second !!!!
The program shows the speed in KBytes / second !
You divided KBytes by 8, but it already shows in KBytes...
No, I divided nothing. :)
1984/8= 248, My speed at the beginning was 256 Kbyte/s
:rolleyes: :bigyello:
The picture shows the speed AFTER my modification.
Before, the speed was 2048 Kilobit/s = 256 Kilobyte/s = 0,256 Megabyte/s = 0.000256 Gigabyte/s. Just to make sure that i know these things. :)
The hint with the "&" works fine! But the speed won't go over 10.000 kbyte/s
CVMichael
Nov 1st, 2006, 09:01 AM
OMG, you have to learn your limits.... first of all, how on earth could you send 10 MBytes / second on a real internet connection ? Why would you want to transfer a file from your comptuer to the same comptuer using Winsock.... why not just copy & paste the file the regular way ?
And also, you said it won't go over 10 MBytes / sec ? well, do this:
Copy a file from a directory to another (on the same hard drive), and the speed won't be much faster than that...
The hard drive has to read 10 MBytes / second, and it has to write the same 10 MBytes back to the same hard drive, so your computer has to handle 20 MBytes / second !
Stop testing this on a local computer, and use a real internet connection ! and then you don't need to make the buffer that big because it cannot transfter that much anyways because of internet limitations....
DrGonzo
Nov 1st, 2006, 09:50 AM
I've just tested the program. I'm now not going to use it for any file i will copy on my computer. :ehh:
Did i anoy you with any of the above written? English isn't my mother tongue.
:wave:
CVMichael
Nov 1st, 2006, 10:06 AM
The program is supposed to be used for transfering files over the internet (or network)...
Yea, you got me a little anoyed... but it's OK... from your previous screen shot, I see you are from Germany (or maybe I got it wrong ?)
DrGonzo
Nov 1st, 2006, 11:22 AM
Yes I'm from germany. Could you please write into a PM what was the annoying part...? thx
brian.sykes
Dec 16th, 2006, 10:50 PM
I get the runtime error 70 which is Permission denied on this line of code
Open App.Path & "\" & Clients(Index).FileName For Binary Access Write Lock Write As Clients(Index).FileNum
Any idea's?
It's on frmReceive, the file server under the DataArrival Sub
CVMichael
Dec 17th, 2006, 09:37 AM
If it's a Permission denied error, then there is nothing I can do/change in the program to fix that... only you can, by setting the appropriate permissions to the directory where you have the application
BrendanDavis
Dec 17th, 2006, 11:41 AM
Yea, I have cable modem too but it's 128 KBits / second Upload and 1 MBit/second download.
If you notice the values are in Bits, so you have to divide by 8 to get Bytes...
So really it's 16 KBytes/second upload, and 128KBytes/second download.
My program shows the speed in KBytes / second...
You have one slow cable modem, then :confused: I topped mine out downloading off a good server at just over 2mb/s. I downloaded a 20 MB file in less than 10 seconds, in other words.
CVMichael
Dec 17th, 2006, 03:34 PM
You have one slow cable modem, then :confused: I topped mine out downloading off a good server at just over 2mb/s. I downloaded a 20 MB file in less than 10 seconds, in other words.
How much do you pay per month ?
I can choose to have higher speed from my provider if I pay more (of course), I think the highest is about the speeds you just mentioned, but is aproximatelly $60 (Canadian $) here. Now I'm paying $30 per month.
evan29
Feb 11th, 2007, 06:08 AM
Hey I've modified your code and it became more effective in sending. you don't need to increase packet size to send faster. I've disabled the timer and found a workaround. Replace your SendComplete event with this:
Private Sub SckSendFile_SendComplete()
'Finish off the send complete first with DoEvents, then immediately send the data
DoEvents
Call tmrSendFile_Timer 'Send the data
End Sub
It have just used "DoEvents" rather than the timer. You should find that it sends a lot faster on fast networks like LAN (not limited to 256 KB/s) and does not need a timer. It should be only slightly faster over slower connections. The "DoEvents" really did work well for me.
DrGonzo
Mar 11th, 2007, 01:01 PM
Hi!
I just wanted to say that nowadays in big cities for example here in germany like cologne or stuttgart VDSL with an effective download data rate of 50 Mbit/s (that are 6,25 Mb/s) and an upload data rate of 10 Mbit/s are very common. These cost 50 euro or 75 C $. :bigyello: :thumb:
But even in german villages you can get ADSL or even ADSL2 and ADSL2+ with data rates up to 25 Mbit/s (3,125 Mb/s).
Pedromiba
Jun 28th, 2007, 08:24 AM
but this program of the one to send of a person for the other???
What are in different places???
Please they answer.
CVMichael
Jun 28th, 2007, 12:33 PM
but this program of the one to send of a person for the other???
What are in different places???
Please they answer.
What ? :confused:
I need a translator to propper English here...
Pedromiba
Jun 28th, 2007, 03:29 PM
I'm sorry i don't speak English very well!! LOL
I with the presented program can send filing-cabinets for other people?
CVMichael
Jun 28th, 2007, 08:21 PM
"filing-cabinets" ??
If those "filing-cabinets" are files, then I don't see the problem... the program sends any file, regardless of the type
Pedromiba
Jun 29th, 2007, 04:31 AM
my problem is not this. my problem is:
“with this program, I can send filing-cabinets of a computer for another one??”
Pedromiba
Jun 29th, 2007, 04:32 AM
filing-cabinets = Files
Pedromiba
Jun 29th, 2007, 04:44 AM
my problem isn't that. my problem is :
""with this program can i send files of a computer for another one??"
CVMichael
Jun 29th, 2007, 07:32 AM
Yes you can... did you actually try it ?
But please don't post every minute, you can edit your posts, and make corrections if you need to.
Pedromiba
Jun 29th, 2007, 05:01 PM
I try.
but i can't send files for other pc's.
how i do this????
CVMichael
Jun 29th, 2007, 08:28 PM
Let's say you are a car repair man, and someone comes to you and tells you fix my car, it does not work... will you know what to fix ? will you know where to even start checking ?
But if if he tells you that the back right lights are not working, then you know where to start looking for problems, right ?
So... if you just tell me "i can't send files", how do you think I'll know where the problem is ?
And besides that... programs don't work the same way on every computer... a lot of things can iterfere with the program, firewall, router, antivirus, operating system, etc...
What did you try ?
What works, and what does not work ?
Tell me something usefull !
If you continue to ask for help like this... then it will take a hell of a lot of time to get your problem solved !
rack
Jul 8th, 2007, 07:16 PM
Just wondering, why is your file size for the program limited to 2gb? I know I would never download or transfer that much, I'm just wondering.
CVMichael
Jul 8th, 2007, 08:56 PM
Because it's using a Long data type to keep track of stransfer size.
A long has a maximum of 2 GBytes (2^31 = 2,147,483,648)
Change the variable type to Double, and you can transfer Terabytes of data...
BrendanDavis
Jul 13th, 2007, 12:22 PM
How much do you pay per month ?
I can choose to have higher speed from my provider if I pay more (of course), I think the highest is about the speeds you just mentioned, but is aproximatelly $60 (Canadian $) here. Now I'm paying $30 per month.
I pay $40 a month US. Don't know how much that is Canadian (even though I used to live there, lol). i think the exchange rate these days is .97 / dollar, or at least it was a week or two ago. so it's not THAT much more in canadian.
MrBeaker
Jul 30th, 2007, 07:00 AM
Just wondering if you had any thoughts on how to transfer multiple files to the server :rolleyes:
Thanks...
CVMichael
Jul 30th, 2007, 07:20 AM
Well, the server acceps more than 1 client, so send the files with more than one client...
Or, modify the client so that when it's done sending the current file, to load another file from a list, and send that one, and so on...
ppitta
Sep 13th, 2007, 08:48 AM
Hi CVMichael,
for couples of weeks i have been trying to write a client/server application (1 server with multi-clients) which can send and receive files (bidirectional).
without success, until today i land on your article on this great site. my problem was to handle more than one client while sending/receiving files, but with ur example code i think my life become a bit easier, i will ask for help just in case i'm having difficulties. :eek2:
pp
ganeshmoorthy
Sep 24th, 2007, 11:51 AM
The coding is really amazing....but Im trying to do the other way around...
Is there anyway I can use this code to send file from one server to multiple clients instead from multiple clients to one server...actually I have connected multiple printing machines to a server and all the production files I would like to transfer from a server thru network. Total Clients I have 5 and I will be transferring multiple files to each machine. The size of the files will be 25 MB to 50 MB and I got attracted by your code since it can transfer any size of file.
Any help?
CVMichael
Sep 24th, 2007, 12:26 PM
If you transfer through local network, then there is a much better solution...
Right now, (if you reverse), when you send a file that is 50 MBytes * 5 times, that will be 250 MBytes sent over the network.
But... if you use UDP connection, you can broadcast the file to ALL computers at the same time, therefore if you send 50 MB to 5 clients, you are sending only 50 MBytes over the network ! You don't even have to specify the target computer to send to, as long as there is a program listening on the port on the client computer, they will pick up the file.
But since it's UDP, you probaly also have to add a CRC (or something like that) to make sure (on the client side) that you received the entire file.
Here is a related thread (To see how to broadcast):
VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY) (http://www.vbforums.com/showthread.php?t=422722)
I don't have time right now to make an example on how to do this (maybe when I get home)
ganeshmoorthy
Sep 24th, 2007, 12:54 PM
If I use these forms in my two different projects (Client Form in one project and Server From in other project) Im getting Type Mismatch error at line FitTextInListView Me.lstConnections, 1, , K + 1 at the tmrStatus_Timer() at the ServerReceive Module
ganeshmoorthy
Sep 24th, 2007, 01:00 PM
If you transfer through local network, then there is a much better solution...
Right now, (if you reverse), when you send a file that is 50 MBytes * 5 times, that will be 250 MBytes sent over the network.Yes, Im transferring thru the local network only (LAN)
I will be sending different set of files from the data process pc to each printing machine...that is for the Machine1, I will send the files for Job No. 1234, Machine2, I wll send the files for Job No. 1235 and so on...
I dont want to broadcast the files instead choosing some set of files to each machines based on the job number specified. And also I want to pass the information of the directory where it has to be stored.
Hope Im not confusing...If you want me to explain it more, I will do
CVMichael
Sep 24th, 2007, 01:48 PM
Hi ganeshmoorthy,
I understand now... before I assumed you send the same file to all computers...
As I was saying before, right now I'm at work, and I don't have time, but hopefully I'll remember to make an example for you when I get home. I will probably add the example as a new thread in the CodeBank...
PS, how do you know what file to send to each computer appon connection ?
CVMichael
Sep 24th, 2007, 10:17 PM
I started making the sample application, but it's gonna take a few days because it's a little complicated and I don't have a lot of time per day to do this. It's gonna be multithreaded & using API for file read/write (therefore files greater than 2GB).
But I need you to answer to my question so I know how to make the sample: How do you know what file to send to each client when it connects ?
Is the client requesting for a file ?
Or you just send file "X" when the IP matches with a list you already set in the server ?
Or some other criteria ?
ppitta
Sep 24th, 2007, 11:30 PM
Hi ganeshmoorthy,
i have manage to play arround with this code, and come up with something like you want, coz i had the same problem before.
By adding receiving functionality to the client (from the server) and sending functionality to the server(from client), can send and receive files. Note you can receive files from the server as long the file is in the server's folder.
i went further, by modifying this code to fit my requirements, now i can send and receive multiple files. in the attached modified version file there is server and part of client code which can send and receive multiple files.
ppitta
Sep 25th, 2007, 12:31 AM
CVMichael
I'm trying to develop a client -server application,
where by users (on client side) need to attach(upload) and view(download) files from server machine.
which is best way to use to store my files between
1) using database to store files or
2) writing server application to receive and send files to the clients, like the one u provided.
ganeshmoorthy
Sep 27th, 2007, 01:37 AM
Thank you very much for your interest in making a sample for me !!!But I need you to answer to my question so I know how to make the sample: How do you know what file to send to each client when it connects ?The user will select multiple files from a flexgrid and click on the send button.
ganeshmoorthy
Sep 27th, 2007, 01:40 AM
ppita,
thank you very much for your work...let me check the code and get back to you..
CVMichael
Sep 27th, 2007, 07:25 AM
The user will select multiple files from a flexgrid and click on the send button.
So, where is the flexgrid ? on the server or on the client ?
In other words, the user on the server decides what to send to client ? Or the client decides what he/she wants to receive from the server ?
PS. I need a few more days to finish it, until now I had bad luck (yesterday there was no power in the whole building, so I could not even start the computer)
ganeshmoorthy
Sep 27th, 2007, 07:59 AM
In other words, the user on the server decides what to send to client ? Or the client decides what he/she wants to receive from the server ?The user on the server decides what to send to client...
PS. I need a few more days to finish it, until now I had bad luck (yesterday there was no power in the whole building, so I could not even start the computer)My bad....
Touchdrop
Jul 31st, 2009, 06:18 AM
Hi,
In continuation to sending file thru Winsock I have a question.
I have a Server receiving data from a ADConverter[with TCP/IP Interface] thru winsock W1.
Now I have 2 other Displays and 6 PCs where the data received is to be displayed. The DIsplay Units are having TCP/IP interface.
In my server program I have incorporated two other winsock W2, W3.
Indivisually when I am sending data to W2 or W3 by senddata each of them are displaying data on dataarrival from W1.
Problem is if I connect W3 after W2, the display on Display-W2 stops but Display-W3 working and vice versa.
Any solution.... URGENTLY NEEDED.
Thax & Regards.
SG
leon100243
Aug 6th, 2009, 12:36 AM
why....?
Please help me~
volkore
Nov 24th, 2009, 12:48 AM
how can i get the file send by the client?where can i find it?
i need some help..plss..
CVMichael
Nov 24th, 2009, 10:58 AM
Hi volkore, welcome to the forums :wave:
The file is in the server's application path (wherever the server application is).
If you are running from the IDE, also look here: C:\Program Files\Microsoft Visual Studio\VB98
ohailo
Nov 27th, 2009, 02:35 PM
Wow..your a pro and a insane too....
whatsup
Jan 6th, 2010, 04:55 PM
I have some newb question:
please correct me if i'm wrong.
from the listen code (server) i saw that it listen only to port 8866,
no IP nor host name, need for the connection.
1. so my question is that enough to recieve connection ?
i mean, every computer on the net that send data on this port,
could connect to this server, (in case the server doesn't require any other ID) ?
CVMichael
Jan 6th, 2010, 05:12 PM
A server always listens on the localhost, so that's why you don't have to give an IP, just the port is enough.
The client needs to know what computer to connect to, so it needs an IP, once it knows the computer, then you give the port.
As long as your router (on the server computer) routes the port properly, and the firewall allows the port to be opened, and also allows incomming connections on that port, then the client should be able to connect. And of course the firewall on the client side has to allow outside connections also...
whatsup
Jan 6th, 2010, 05:39 PM
oh, thank you very much, i see now, that it's the client who need to know the IP,
i'll look for that in the code, thank you.
now i have a little problem.
as maybe this ocx might not be installed by default on every pc,
and i don't want to depend on it,
does someone know how to do this task with API ?
i have a full demo code using API only,
to download a file from a site.
but i'd like to know, how to download from another computer.
maybe all i need, is to supply the IP address (converted to num maybe), instead of the site address ?
second question,
is there a way to build an exe file included the ocx ?
it could be much easier instead of using API.
whatsup
Jan 6th, 2010, 06:33 PM
I found a solution for the ocx issue,
there is a program called makesfx, that can make self extracting file and also execute some file after the self extract.
so i can pack all the components i want in one file, and include a setup file in that archive, that will be automatically executed on extract.
CVMichael
Jan 7th, 2010, 04:55 PM
Package & Deployment Wizard comes with VB... why can't you just make a setup for the application ?
whatsup
Jan 11th, 2010, 05:23 AM
because ...
i'd like to do it myself, not an issue.
i have a question
i tried to send/recieve between 2 virtual machines.
they both on the same IP.
i gave to the sender the internet IP (instead of hostname)
but it didn't work.
(on the same machine it works well.)
i hope i could try this with someone on other computer with different IP
maybe it will work :)
anyway thanks for the code.
jlt212000
Feb 15th, 2010, 03:46 AM
i have utilized your software for my passport scanning that saves an image to the server. But my problem is.. the image size saved on the server is 3 to 4 times larger than the image size saved on the client.
client image = 16 Kb
server image = 54 Kb
im trying to minimize as much as possible the image size in the server because there will be a lot of images that will be stored there..
Need help.. thanx.
deepz
Mar 16th, 2010, 11:20 AM
i opened 4556 port and successfully transfered (file size 2 mb) but where does it saving :eek:
and i have tried with localhost too,i cant find that i transfered file :sick:
hope some one will help me
thanks in advanced
//deepz :duck:
CVMichael
Mar 16th, 2010, 01:00 PM
Did you check the App.Path ?
Or did you look in the code to see where it's saving ?
deepz
Mar 16th, 2010, 11:52 PM
Did you check the App.Path ?
Or did you look in the code to see where it's saving ?
you mean this one ???
Clients(Index).FileNum = FreeFile
Open App.Path & "\" & Clients(Index).FileName For Binary Access Write Lock Write As Clients(Index).FileNum
if i want to send C:\WINDOWS\system32
code is
Open App.Path & "C:\WINDOWS\system32" & Clients(Index).FileName
am i correct?
CVMichael
Mar 17th, 2010, 07:45 AM
Why would you transfer files into the systems folder ?
Probably you have to add "\", like
Open App.Path & "C:\WINDOWS\system32\" & Clients(Index).FileName
deepz
Mar 17th, 2010, 10:46 AM
Why would you transfer files into the systems folder ?
Probably you have to add "\", like
Open App.Path & "C:\WINDOWS\system32\" & Clients(Index).FileName
system folder just for example :D
i got error
http://i39.tinypic.com/35cllqr.jpg
plz can attach ur working project file with my path :ehh:
CVMichael
Mar 17th, 2010, 10:49 AM
Does "new folder" exist ?
[edit]
Wait a minute... why you have App.Path & "C:\Windows"...
That will give you path like "C:\somethingC:\Windows"... does that look right to you ?
Remove the App.Path, and make sure "new folder" exists.
Why could'nt you just put a break point at that line, and check the path by yourself ?
deepz
Mar 17th, 2010, 11:45 AM
Does "new folder" exist ?
[edit]
Wait a minute... any you have App.Path & "C:\Windows"...
That will give you path like "C:\somethingC:\Windows"... does that look right to you ?
Remove the App.Path, and make sure "new folder" exists.
Why could'nt you just put a break point at that line, and check the path by yourself ?
put any path ;) im not good at vb :ehh: plz attach ur project file
thanks
starlight
Jun 1st, 2010, 07:55 PM
Hi all,
how can i send the files from PC using Window CE to PC using Window XP and by using LAN connectivity? let PC window CE as slave and PC window XP as master, then how can I ping the ethernet from window XP to make sure the validity of both connection then send a file over PC?
Thanks.
J.J.Johnstone
Jun 9th, 2010, 01:02 PM
How might you go about informing the Client side that the Server is not active/listening?
whatsup
Jul 16th, 2010, 10:26 AM
is there a way to increase the packet size above 4KB, something like 32/64KB ?
i tried this, and it doesn't work. it seems that the limit is 4K.
CVMichael
Jul 16th, 2010, 12:51 PM
The TCP protocol divides the data into 4K packets, so even if you send 100K in one "SendData", it will divide the data in 25, 4K packets. There is absolutely nothing you can do about it.
whatsup
Jul 17th, 2010, 03:20 PM
thank you, i guess my problem was that i didn't wait for the finished transfer event,
i discovered this when i sent two packets one after one,
then i also read what you said about this, you definitely right,
things won't work if you don't wait for this event, unless you send tiny packets.
i also don't use this event to do the transfer (as you said),
in this event i set a flag
and i wait for this flag with do events like this
Private Sub Send(ByVal TheData$)
blnCandSend = True
sck.Send TheData$
While blnCandSend
Do Events
Wend
End Sub
Private Sub sck_SendComplete()
blnCantSend = False
End Sub
Private Sub sck_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
blnCantSend = False
End Sub
Private Sub sck_Close()
blnCantSend = False
End Sub
for me it's better this way, than using a timer.
whatsup
Aug 16th, 2010, 12:58 PM
CV, i found strange thing in vb WinSock
the client send the file header
in three seperated packets
one after one.
but on the server side, they all got as one packet.
i can only guess that this is because WinSock slowly
in my WSocket, these three packets, get as three seperated packets,
there for i changed this to one packet.
here is the attachment with my new WSocket, in your demo project.
the client which doesn't use any ocx, can work on Windows7.
ِAdmiral
Sep 29th, 2010, 09:22 AM
that is not working with RHOST
i test it
CVMichael
Oct 3rd, 2010, 11:41 AM
I have no clue what RHOSt is...
ufo973
Dec 9th, 2011, 10:51 AM
@CVMicheal
I like your code and it was what i was looking for, but i have one question.
How can i send more then one file at the same time from a client (not multiple clients)?
I hope you answer this. Thank You
CVMichael
Dec 9th, 2011, 11:14 AM
It's been a while since I saw this project, but from what I remember if you change the winsock control to a control array, and the rest of the code to create a new instance, and start transfering on that instance.
ufo973
Dec 9th, 2011, 11:19 AM
Can you create a user control out of it? if it is easy and you have time.
CVMichael
Dec 9th, 2011, 12:39 PM
Sorry, I don't do programming in VB6 for a few years, I switched to .NET. And my life has changed dramatically, as you can see I'm not active on the forums anymore. I just answer 5 min questions once in a while.
ufo973
Dec 12th, 2011, 09:11 AM
@CVMichael
I have successfully implemented your code in my 2 projects,
1 to send live webcam captures from server to client,
And my 2nd project a remote file downloader/uploader.
but i don't know what packet sizes should i set for these 2 projects.
Can you give me some idea please? I mean what should be packet size for live webcam captures transfer which requires a fast transmission, and 2nd remote file uploader/downloader?
Thank you very much.
CVMichael
Dec 12th, 2011, 10:21 AM
4Kbytes should be the norm. Anything smaller it will send too often therefore slowing down the connection, anything bigger will be broken up in smaller packets anyways.
ufo973
Dec 12th, 2011, 12:03 PM
So it means increasing the packet size won't increase the upload/download speed?
I have one more problem please,
you implemented stuff like speed, time remaining and bytes sent for sender side, but not in the receiver side which i can't figure out.
Can you please help me with this. Thanks Again
Here is the code from the sender side
Private Sub tmrCalcSpeed_Timer()
Static PrevSent As Long
Dim BSentPerSec As Long, DataSent As Long, DataLen As Long
Dim SecondsLeft As Single
If iFileNum > 0 Then
DataSent = Loc(iFileNum)
DataLen = LOF(iFileNum)
BSentPerSec = DataSent - PrevSent
PrevSent = DataSent
SecondsLeft = (CSng(DataLen) - CSng(DataSent)) / CSng(BSentPerSec)
Else
PrevSent = 0
End If
lblSendSpeed.Caption = Format(DataSent / 1024#, "###,###,##0.00") & " KBytes Sent, " & _
Format(CDbl(BSentPerSec) / 1024#, "#0.00") & " Kb/Sec, " & _
"Time left: " & Format(SecondsLeft \ 3600, "00") & ":" & Format(SecondsLeft \ 60, "00") & ":" & Format(SecondsLeft Mod 60, "00")
End Sub
How i can change it to work with the receiver side?
kholous
Feb 25th, 2012, 12:57 AM
If many person send a similar file we see Error word in the program .
How can correct this action?
Thanks.
ramu123
Feb 26th, 2012, 11:12 PM
hai all can anybody suggest me to "how to get the data in packet by packet format instead of whole stream " plz i hav to submit project soon
ramu123
Mar 13th, 2012, 11:27 PM
hai sir this ramu i hav to read the data at winsock reciever BYTE by BYTE instead of STREAM of data(packet by packet) for that i m using "binary read write mode" but it is not working after sometime it showing the error "DIVISION BY ZERO" problem please help me sir..............
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.