Re: VB - How to send a file using the Winsock control
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 ?
Last edited by CVMichael; Sep 25th, 2007 at 07:35 AM.
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
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.
Last edited by ppitta; Sep 25th, 2007 at 12:52 AM.
Re: VB - How to send a file using the Winsock control
Originally Posted by ganeshmoorthy
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)
Re: VB - How to send a file using the Winsock control
Originally Posted by CVMichael
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...
Originally Posted by CVMichael
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....
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
Re: VB - How to send a file using the Winsock control
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) ?
Re: VB - How to send a file using the Winsock control
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...
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
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
Re: VB - How to send a file using the Winsock control
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..
Re: VB - How to send a file using the Winsock control
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?
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
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
Code:
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.
Last edited by whatsup; Jul 17th, 2010 at 03:26 PM.
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
@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
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
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.
Re: VB - How to send a file using the Winsock control
@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.
Re: VB - How to send a file using the Winsock control
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.