简体   繁体   中英

Send/Receive picture with Socket

Currently developping an application where I must send a picture every X seconds to my server and the server will upload it to my FTP. To not make the picture heavy, its format is JPEG and my last image was 135Ko, which is 135000 bytes.

Usually I send packets of max 8192 bytes, but I need this picture sending mechanism in my application, so I'm here to ask you guys what would be the best way to send those 135000 bytes to my server? A fast way too.

  • All at once?
  • Slice it, 8192 bytes a piece ?
  • Other method that I miss?

EDIT : I use TCP

Thanks for your time.

A TCP Packet Size can go up to 64K (65535 bytes) so:

You will have Three options (yes):

  • Assuming you already convert your image to bytes[], send each image via two packets and then combine on the server side. You will need to watch out for their order.

  • Resize your image so you reach the same packet size or less than it.

  • Search for a library that does it for you (split an image down to several packets and combines it back together)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM