Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Sending File Through UDP

Sending File Through UDP

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminbusinesshelptutorial
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Girish601
    wrote on last edited by
    #1

    Thanks folks for your valuable advice of Tcp over Udp. As far as my requirements are concerned, it demands UDP. Bcoz the scenario is such that we have to broadcast packets at the same to n number of Machines across the network.That's the reason i need help on Sending files over UDP protocol. I have worked previously on TCP,but not on UDP. As far as previous post is concerned,somebody said that it is similar as creating Socket and Sending it using IP and Port. I hope in UDP you are sending on a Broadcast IP and port,so how to do it. Thankx in Advance.

    Girish Software Developer

    R J E 3 Replies Last reply
    0
    • G Girish601

      Thanks folks for your valuable advice of Tcp over Udp. As far as my requirements are concerned, it demands UDP. Bcoz the scenario is such that we have to broadcast packets at the same to n number of Machines across the network.That's the reason i need help on Sending files over UDP protocol. I have worked previously on TCP,but not on UDP. As far as previous post is concerned,somebody said that it is similar as creating Socket and Sending it using IP and Port. I hope in UDP you are sending on a Broadcast IP and port,so how to do it. Thankx in Advance.

      Girish Software Developer

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      Girish601 wrote:

      I hope in UDP you are sending on a Broadcast IP and port,so how to do it.

      Create the socket with a call to CSocket::Create and set the nSocketType parameter to SOCK_DGRAM for UDP. If the socket was successfully created you can use CSocket::SendTo for sending datagrams to whatever address and port you desire since both shall be provided as formal parameters. If you're not using MFC you can use the raw socket API, but I think you get the picture. Hope this helps -- Roger


      "It's supposed to be hard, otherwise anybody could do it!" - selfquote

      "No one remembers a coward!" - Jan Elfström 1998
      "...but everyone remembers an idiot!" - my lawyer 2005 when heard of Jan's saying above

      1 Reply Last reply
      0
      • G Girish601

        Thanks folks for your valuable advice of Tcp over Udp. As far as my requirements are concerned, it demands UDP. Bcoz the scenario is such that we have to broadcast packets at the same to n number of Machines across the network.That's the reason i need help on Sending files over UDP protocol. I have worked previously on TCP,but not on UDP. As far as previous post is concerned,somebody said that it is similar as creating Socket and Sending it using IP and Port. I hope in UDP you are sending on a Broadcast IP and port,so how to do it. Thankx in Advance.

        Girish Software Developer

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        It is very similar, except that datagrams (UDP messages) have a maximum size, and there is no guaranteed delivery or sequencing/ordering of data.    With TCP, if you send 128KB of data with a single call, internally it will be broken up (if necessary) into smaller packets (either on your system or possibly further down the network) that will be reassembled on the receiving system.    With UDP, IIRC, if you try to send 32KB with a single call, only a certain amount of it will be sent (something like 1500 bytes, I think).  You will need to break up the data yourself into packets and send them one at a time.  Additionally, if you send 5 packets in a row (1,2,3,4,5), they may arrive on the other side out-of-sequence (1,2,_**4,5,3**_), or some may not make it at all (1,3,**_4,2_** but no 5th datagram).    Sending multiple-packets of data via UDP often requires that you implement your own packetizing logic so that you handle lost or out-of-sequence packets.    Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC.  You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        T 1 Reply Last reply
        0
        • G Girish601

          Thanks folks for your valuable advice of Tcp over Udp. As far as my requirements are concerned, it demands UDP. Bcoz the scenario is such that we have to broadcast packets at the same to n number of Machines across the network.That's the reason i need help on Sending files over UDP protocol. I have worked previously on TCP,but not on UDP. As far as previous post is concerned,somebody said that it is similar as creating Socket and Sending it using IP and Port. I hope in UDP you are sending on a Broadcast IP and port,so how to do it. Thankx in Advance.

          Girish Software Developer

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          Girish601 wrote:

          I have worked previously on TCP,but not on UDP. As far as previous post is concerned,somebody said that it is similar as creating Socket and Sending it using IP and Port.

          No big difference. It still requires port & IP.

          Girish601 wrote:

          I hope in UDP you are sending on a Broadcast IP and port,so how to do it.

          It's not "in UDP we broadcast". Broadcast is done if we want to. For sending files I dont think UDP would be the best option. But in LAN environment, it's success rate is 99%. The main difference is, it's connectionless protocol that means it doesn't maintain any connection between the server & client. Just "push" the data and "get" the data. No connection path is set up in between. let me give you a link ..please wait.


          Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.

          1 Reply Last reply
          0
          • J James R Twine

            It is very similar, except that datagrams (UDP messages) have a maximum size, and there is no guaranteed delivery or sequencing/ordering of data.    With TCP, if you send 128KB of data with a single call, internally it will be broken up (if necessary) into smaller packets (either on your system or possibly further down the network) that will be reassembled on the receiving system.    With UDP, IIRC, if you try to send 32KB with a single call, only a certain amount of it will be sent (something like 1500 bytes, I think).  You will need to break up the data yourself into packets and send them one at a time.  Additionally, if you send 5 packets in a row (1,2,3,4,5), they may arrive on the other side out-of-sequence (1,2,_**4,5,3**_), or some may not make it at all (1,3,**_4,2_** but no 5th datagram).    Sending multiple-packets of data via UDP often requires that you implement your own packetizing logic so that you handle lost or out-of-sequence packets.    Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC.  You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).    Peace!

            -=- James
            Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            See DeleteFXPFiles

            T Offline
            T Offline
            Tim Paaschen
            wrote on last edited by
            #5

            James R. Twine wrote:

            Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC. You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).

            I'm currently doing some research on broadcast and multicast, as we plan to use it in one of our projects. All documents I found so far claim that broadcasing and multicasting require the use of UDP. This does make sense to me, as TCP requires an established connection and for broadcasing and multicasting you don't even know to how many recepicients you are talking.

            Regards, Tim

            J 1 Reply Last reply
            0
            • T Tim Paaschen

              James R. Twine wrote:

              Broadcast, point-to-point, point-to-multipoint or multicast has nothing to do with your using TCP or UDP, IIRC. You can data using either style to a broadcast address (i.e. xxx.xxx.xxx.255), or to a multicast address (multicast router, for example).

              I'm currently doing some research on broadcast and multicast, as we plan to use it in one of our projects. All documents I found so far claim that broadcasing and multicasting require the use of UDP. This does make sense to me, as TCP requires an established connection and for broadcasing and multicasting you don't even know to how many recepicients you are talking.

              Regards, Tim

              J Offline
              J Offline
              James R Twine
              wrote on last edited by
              #6

              Tim Paaschen wrote:

              All documents I found so far claim that broadcasing and multicasting require the use of UDP. This does make sense to me, as TCP requires an established connection and for broadcasing and multicasting you don't even know to how many recepicients you are talking.

              Interesting...   I think that makes sense for things like using PING to try to ping a broadcast address, but not for multicast that is supported by the network hardware.  Since one or more routers could handle connetions to multiple clients, and since the connections are one-way, connection or connection-less would not matter - clients would subscribe to the 'cast by subscribing to the multicast server.  But then again, I have not been close to multicast for some time now, so my memory of it may be faulty.    Peace!

              -=- James
              Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
              Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
              See DeleteFXPFiles

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups