• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

End of file JPG images

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I am sending many images from my server to client in sequence continuously through TCP.Now at client,how should i detect that this is end of my one image so write it down in file system and then next image and so on.

Best regards,
...
 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do not you send ETX ( Hex - 03) end of transmission flag to indicate that image is completed.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why do not you send ETX ( Hex - 03) end of transmission flag to indicate that image is completed.


That won't work - binary files can contain any byte sequence as part of the data.

You should implement a simple transmission sequence, like: 1) send # of images (2 bytes), 2) send size of image #1 (4 bytes), 3) send image data #1, and then repeat steps 2 and 3 as many times as required.
 
zainu Mehmood
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention.I am getting byte[] array of valid JPG image and sending that byte[] image by image through socket byte[] at a time and so on.Now at client client side i am receiving data in chunks and now just need to identify the eof.Things are very simple so far and i dont wana make them complex by introducing different kind of headers.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"For every complex problem there is a solution that is simple, neat and wrong" - H L Mencken
 
zainu Mehmood
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:"For every complex problem there is a solution that is simple, neat and wrong" - H L Mencken


Love it
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

Why do not you send ETX ( Hex - 03) end of transmission flag to indicate that image is completed.


That won't work - binary files can contain any byte sequence as part of the data.

You should implement a simple transmission sequence, like: 1) send # of images (2 bytes), 2) send size of image #1 (4 bytes), 3) send image data #1, and then repeat steps 2 and 3 as many times as required.



this is surprising to me as I never encountered STX (0x02) and ETX(0x03) as a data.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:"For every complex problem there is a solution that is simple, neat and wrong" - H L Mencken


love it man
 
Attractive, successful people love this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic