Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : SendText() works, SendBuf() fails
| Subject: | SendText() works, SendBuf() fails |
| Posted by: | "Clay Shannon" (blac..@redgreen.com) |
| Date: | Tue, 14 Nov 2006 17:41:07 |
I have created an app to test the reception of messages in my "real" app
(the test app emulates the RealTime system sending socket messages).
Both apps (test and real) are using the (deprecated)
TClientSocket/TServerSocket components.
BDS2006. Mode is NonBlocking.
First, I got the sending of strings working. IOW, this procedure works:
procedure TForm10.btnSendStrMsgClick(Sender: TObject);
var
s: String;
begin
ClientSocket.Active := True;
s := Memo1.SelText;
if Trim(s) <> '' then
ClientSocket.Socket.SendText(s)
else
ClientSocket.Socket.SendText(Memo1.Lines[0]);
end;
It fires several events in the "real" app, such as ServerSocket.OnGetSocket,
ServerSocket.OnClientConnect on the first message, ServerSocket.OnClientRead
on subsequent messages sent, ServerSocket.OnAccept, and
ServerSocket.OnClientWrite.
However, I'm trying now to send Records (that's what the RealTime coder,
working with C and Linux, wants to send (structs)), and the following is NOT
working:
procedure TForm10.SendActiv8BOFSortRecord;
var
X: PActivateBOFSort;
begin
X := AllocMem(SizeOf(TActivateBOFSort));
X^.OpCode := ACTIVATE_BOF_SORT;
X^.Carrier := StrToIntDef(edt1.Text, 0);
StrLCopy(X^.BOFSortLabel, PChar(edt2.Text), BOF_SORT_LABEL_LENGTH);
X^.WorkstationOffset := StrToIntDef(edt3.Text, 0);
ClientSocket.Socket.SendBuf(X^, SizeOf(TActivateBOFSort));
end;
Specifically, SendBuf() doesn't fire any of the event handlers in the "real"
app.
SendText() works like gangbusters, but SendBuf() falls flat on its face.
Why?
--
Download my historical nonfiction and/or satirical (etc.) fiction books free
from here:
http://www.lulu.com/blackbirdcraven