• Post Reply Bookmark Topic Watch Topic
  • New Topic

End of file JPG images

 
zainu Mehmood
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • 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,
...
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do not you send ETX ( Hex - 03) end of transmission flag to indicate that image is completed.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Likes 3
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Mihai Calin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!