Thanks Lukas for taking the time to answer.
>You must read data by recvpacket. You must examine each received packet
and try to find begin of your image on the begin of received datagram.
Then add all next datagrams into your image data, until you find next
starting datagram.
The problem is that every ansistring receiving RecvPacket starts with the
beginning of the packet, but never contains the end, the next iteration of
RcvPacket will contain the beginning of the next packet but not the end of
the 1st one. So how can I access these ends ?
for now, my dirty test code is as follow, I can find the start of JPG, the
offset of the lastbut not the end :
var
Sock:TUDPBlockSocket;
soffset:smallint;
eoffset:smallint;
buf:ansistring;
begin
Sock:=TUDPBlockSocket.Create;
try
Sock.bind('192.168.0.88','49199');
if Sock.LastError<>0 then exit;
while True do
begin
buf := Sock.RecvPacket(50);
if Sock.lasterror=0 then
size := length(buf);
soffset := ord(buf[32])+33;
eoffset := 4096*(hextoint(intToHex(ord(buf[1]),2)[1])) +
256*(hextoint(intToHex(ord(buf[1]),2)[2]))+16*((hextoint(intToHex(ord(buf[2]),2)[1]))+
hextoint(intToHex(ord(buf[2]),2)[2]));
writeln ('real size : '+inttostr(eoffset));
writeln ('start of JPG : '+inttostr(soffset));
writeln ('check of start of JPG : '+
intToHex(ord(buf[soffset]),2)+intToHex(ord(buf[soffset+1]),2));
writeln ('end of JPG : '+inttostr(eoffset));
writeln ('check of end of JPG : '+
intToHex(ord(buf[eoffset]),2)+intToHex(ord(buf[eoffset+1]),2));
sleep(50);
end;
Sock.CloseSocket;
finally
Sock.free;
end;
end.
2013/5/26 Lukas Gebauer <gebyl...@mlp.cz>
> > We don't understand each other when speaking about datagram, I'm not
> using
> > "datagram based" communication, my camera (which I can't modify) send
> > those UDP "packets" if you prefer, which are transmitted in 1514 byte
> > fragments , but this should be transparent to the program as those
> packets
> > are reassembled at the OS level.
>
> Do not mix datagram with frames. Frames does not matter, because we are
> operating on packet level.
>
> UDP = "User DATAGRAM Protocol" It is based on sending datagram packets.
> (see: http://en.wikipedia.org/wiki/User_Datagram_Protocol)
>
> And each datagram packet have limited maximum size. Technically it is
> nearly 64kB on IPv4. But maximum datagram size is limited by an operating
> system too! It is indicated by iMaxUdpDg member of WSAdata structure.
>
> Check TUdpBlockSocket.WSAdata.iMaxUdpDg value... it is 8192 in your case,
> am I right? So, then you cannot use larger UDP datagram. UDP is designed
> for small data, not for large data transfers.
>
> In Synapse TUDPBlockSocket practise - one send operation made one
> datagram on the wires. (it can be just one byte of data, or more... up to
> iMaxUdpDg.) One Recvpacket call receive one datagram from reading queue.
> Dunno how it is big. You got full datagram by one call.
>
> Using other receiving funtiocn working too (because it using recvvPacket
> on the background), but it is not reliable! UDP datagram can be lost - do
> not forget it!
>
> What happen, when you wish to read X bytes, but some datagram was lost?
> Missing bytes is readed from the beginning of next image and you are
> totally unsychronized! It is worst kind of error, because your program
> working fine... until first data lost occurs. Then your program do crazy
> things.
>
> You must read data by recvpacket. You must examine each received packet
> and try to find begin of your image on the begin of received datagram.
> Then add all next datagrams into your image data, until you find next
> starting datagram. Sometimes you can get invalid image, but you are
> always synchronized.
>
> --
> Lukas Gebauer.
>
> http://synapse.ararat.cz/ - Synapse Delphi and Kylix TCP/IP Library
> http://geoget.ararat.cz/ - Geocaching solution
>
>
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> synalist-public mailing list
> synalist-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/synalist-public
>
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public