-
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 ?
-
2 Attachment(s)
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.
-
Re: VB - How to send a file using the Winsock control
Thank you very much for your interest in making a sample for me !!!
Quote:
Originally Posted by CVMichael
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.
-
Re: VB - How to send a file using the Winsock control
ppita,
thank you very much for your work...let me check the code and get back to you..
-
Re: VB - How to send a file using the Winsock control
Quote:
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
Quote:
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...
Quote:
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....
-
Re: VB - How to send a file using the Winsock control
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
-
1 Attachment(s)
Re: VB - How to send a file using the Winsock control
-
Re: VB - How to send a file using the Winsock control
how can i get the file send by the client?where can i find it?
i need some help..plss..
-
Re: VB - How to send a file using the Winsock control
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
-
Re: VB - How to send a file using the Winsock control
Wow..your a pro and a insane too....
-
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
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.
-
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
Package & Deployment Wizard comes with VB... why can't you just make a setup for the application ?
-
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 :)
anyway thanks for the code.
-
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..
Need help.. thanx.
-
Re: VB - How to send a file using the Winsock control
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:
-
Re: VB - How to send a file using the Winsock control
Did you check the App.Path ?
Or did you look in the code to see where it's saving ?
-
Re: VB - How to send a file using the Winsock control
Quote:
Originally Posted by
CVMichael
Did you check the App.Path ?
Or did you look in the code to see where it's saving ?
you mean this one ???
Code:
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
Code:
Open App.Path & "C:\WINDOWS\system32" & Clients(Index).FileName
am i correct?
-
Re: VB - How to send a file using the Winsock control
Why would you transfer files into the systems folder ?
Probably you have to add "\", like
Code:
Open App.Path & "C:\WINDOWS\system32\" & Clients(Index).FileName
-
Re: VB - How to send a file using the Winsock control
Quote:
Originally Posted by
CVMichael
Why would you transfer files into the systems folder ?
Probably you have to add "\", like
Code:
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:
-
Re: VB - How to send a file using the Winsock control
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 ?
-
Re: VB - How to send a file using the Winsock control
Quote:
Originally Posted by
CVMichael
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
-
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?
Thanks.
-
Re: VB - How to send a file using the Winsock control
How might you go about informing the Client side that the Server is not active/listening?
-
Re: VB - How to send a file using the Winsock control
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.
-
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.
-
1 Attachment(s)
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
that is not working with RHOST
i test it
-
Re: VB - How to send a file using the Winsock control
I have no clue what RHOSt is...
-
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
Can you create a user control out of it? if it is easy and you have time.
-
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.