Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 86

Thread: VB - How to send a file using the Winsock control

  1. #41

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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.

  2. #42
    New Member
    Join Date
    Sep 2007
    Posts
    3

    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.
    Attached Files Attached Files

  3. #43
    New Member
    Join Date
    Sep 2007
    Posts
    3

    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.

  4. #44
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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.
    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.


  5. #45
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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..
    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.


  6. #46

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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)

  7. #47
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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....
    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.


  8. #48
    New Member
    Join Date
    Jul 2009
    Posts
    2

    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

  9. #49
    Member
    Join Date
    Apr 2009
    Posts
    37

    Re: VB - How to send a file using the Winsock control

    why....?
    Please help me~
    Attached Images Attached Images  

  10. #50
    New Member
    Join Date
    Nov 2009
    Posts
    1

    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..

  11. #51

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: VB - How to send a file using the Winsock control

    Hi volkore, welcome to the forums

    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

  12. #52
    Junior Member
    Join Date
    Nov 2009
    Posts
    19

    Re: VB - How to send a file using the Winsock control

    Wow..your a pro and a insane too....

  13. #53
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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) ?

  14. #54

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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...

  15. #55
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.

  16. #56
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.

  17. #57

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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 ?

  18. #58
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.

  19. #59
    New Member
    Join Date
    Feb 2010
    Posts
    1

    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.

  20. #60
    New Member
    Join Date
    Mar 2010
    Posts
    4

    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

    and i have tried with localhost too,i cant find that i transfered file

    hope some one will help me
    thanks in advanced

    //deepz

  21. #61

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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 ?

  22. #62
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: VB - How to send a file using the Winsock control

    Quote Originally Posted by CVMichael View Post
    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?

  23. #63

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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

  24. #64
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: VB - How to send a file using the Winsock control

    Quote Originally Posted by CVMichael View Post
    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

    i got error



    plz can attach ur working project file with my path

  25. #65

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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 ?
    Last edited by CVMichael; Mar 17th, 2010 at 11:52 AM.

  26. #66
    New Member
    Join Date
    Mar 2010
    Posts
    4

    Re: VB - How to send a file using the Winsock control

    Quote Originally Posted by CVMichael View Post
    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 plz attach ur project file

    thanks

  27. #67
    New Member
    Join Date
    May 2010
    Posts
    5

    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.

  28. #68
    Junior Member
    Join Date
    Aug 2002
    Posts
    24

    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?

  29. #69
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.

  30. #70

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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.

  31. #71
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.

  32. #72
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    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.
    Attached Files Attached Files

  33. #73
    New Member
    Join Date
    Dec 2009
    Posts
    5

    Re: VB - How to send a file using the Winsock control

    that is not working with RHOST
    i test it

  34. #74

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    Re: VB - How to send a file using the Winsock control

    I have no clue what RHOSt is...

  35. #75
    Lively Member
    Join Date
    Oct 2011
    Posts
    126

    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

  36. #76

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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.

  37. #77
    Lively Member
    Join Date
    Oct 2011
    Posts
    126

    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.

  38. #78

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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.

  39. #79
    Lively Member
    Join Date
    Oct 2011
    Posts
    126

    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.

  40. #80

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802

    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.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width