471,075 Members | 749 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

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!
Nov 14 '08 #1
3 5939
7,872 Expert 4TB
.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.
Nov 14 '08 #2
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!
Nov 14 '08 #3
3,525 Expert 2GB
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?
Nov 15 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Nuno Magalhaes | last post: by
2 posts views Thread by djc | last post: by
11 posts views Thread by hazz | last post: by
2 posts views Thread by manasap | last post: by
2 posts views Thread by Ali Hamad | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.