c# socket.send()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EricKit
    New Member
    • Nov 2008
    • 2

    c# socket.send()

    I'm trying to use socket.send() to send real time images from a camera as fast as possible from a single board computer. I am going over a wireless connection over a mile with almost 1W output power on 802.11.

    For many reasons, I have seen the need to find when my file has finished sending, but the socket.send only blocks until it has pushed the file to the buffer. Is there any way to check if the buffer is empty and the file sent?

    Beginsend and beginsend file do not send the files like I would like (they send it in multiple packets that will require a protocol written to receive), however they do wait until they are all sent. Thank you!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    .Send() returns an integer value, you could look at that to see how much of the byte[] was sent?
    And sending it as multiple packets should not require any extra effort on the receiving end. The data will pretty much ALWAYS be sent as multiple packets.
    Only 1500bytes (a little over 1k) are transfered in a standard packet, and that includes the headers I believe.

    Comment

    • EricKit
      New Member
      • Nov 2008
      • 2

      #3
      I agree that it will always be broken up. However, socket.send() and socket.receive( ) work very nice with each other up to 1MB. The .receive will take all 1MB in, not knowing the size, and report the size it received, which was sent in many packets. This is why I want to know when it is finished sending, so I can start sending the next image. If I start sending the next image right away, TCP starts sending both packets at the same time, and the .receive starts receiving many tiny fragments the size of a packet.

      The integer it returns in the number of bytes sent to the buffer, not the number of bytes actually sent successfully via TCP to the remote client.

      So, the only question I really have is how to check when the file is physically sent (when the buffer is empty).

      Thanks again!

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Is the program you are sending to of your design? Maybe you can just use some type of query/response to ask it if the image was received, and get a response of the size. If the sizes match then you're good?

        Comment

        Working...