[prev in list] [next in list] [prev in thread] [next in thread] 

List:       twsocket
Subject:    Re: [twsocket] question (sending binary data through socket)
From:       "Francois PIETTE" <francois.piette () overbyte ! be>
Date:       2004-01-31 9:13:31
Message-ID: 02b701c3e7db$8c6ddc50$6a01a8c0 () TOSHIBA2
[Download RAW message or body]

> OnDataAvailable
>   ... // processing client request
>   Client.Send(MyBuffer, MyLen); // answer, huge binary data block,
>                                 // sometimes AV here

There is nothing wrong in this code, provided MyBuffer is a valid pointer to
your data. When the AV occurs, is that pointer correctly pointing to valid
data ? For example, MyBuffer could be a pointer to a local variable out of
scope at the time the function is called.

Just to see if the pointer is valid, add code like this just before
Client.Send:

var
    Temp : String;

SetLength(Temp, MyLen);
Move(MyBuffer^, Temp[1], MyLen);

If the pointer is not valid, then Move will trigger an AV and you'll know
that the problem is in your code.

If this doesn't give any result then you should add wsocket.pas to your
project so that if the AV occur inside the Send method you'll see exactly
where (and report that here).

--
francois.piette@overbyte.be
http://www.overbyte.be


----- Original Message ----- 
From: "PS" <trash1975@mail.ru>
To: <twsocket@elists.org>
Sent: Saturday, January 31, 2004 2:07 AM
Subject: [twsocket] question (sending binary data through socket)


> I've got AV from time to time in my programm, looks like I just don't
understand
> what logic is correct for my case.
> Here is the example:
>
> OnDataAvailable
>   ... // processing client request
>   Client.Send(MyBuffer, MyLen); // answer, huge binary data block,
>                                 // sometimes AV here
>
> I've looked at sendfile example, and seems to me I should change my code
like:
>
> OnDataAvailable
>   ... // processing client request
>   Client.PutHugeBinaryAnswerToBuffer(...); // not Send here !!!
>
> Client.OnDataSent
>   if (Error = 0) and (BinaryBuffer is not empty) then
>     PostMessage(Handle, WM_SENDBINARYDATA, 0, LongInt(Sender));
>
> WM_SENDBINARYDATA processing: send binary data to client (Send here).
>
> The question is: could such code reorganization resolve my AV problem or
should I change my code some other way ?
>
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic