Article View: comp.lang.pascal.delphi.misc
Article #46Re: C++/Delphi sockets question
From: Fran�ois Piette
Date: Tue, 30 Jun 1998 00:00
Date: Tue, 30 Jun 1998 00:00
56 lines
2645 bytes
2645 bytes
> OK in Delphi I can use the winsock API send() function like this:
>
> type
> TMyThing=record
> AMember: array[0..100] of char;
> ANOther: integer;
> YetANOther: TMyOtherThing;
> end;
>
> procedure Form1.Button1Click(Sender: TObject);
> var
> thing: TMyThing;
> begin
> {populate thing here}
> .
> .
> if send(asocket,thing, sizeof(TMyThing,0)<>sizeof(TMyThing) then
> {do some error handling}
> end;
>
> this seems to be because the winsock.pas header file describes send()
> as:
>
> function send(s: TSocket; var Buf; len, flags: Integer): Integer;
> stdcall;
>
> where the send buffer is a var pointer type.
>
> unfortunately in C++ Builder, winsock.h declares send() as:
>
> int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int
> flags);
>
> note the use of const char FAR * as the type for the send buffer. When I
> create a similar TMyType in C++ I cant send it down my socket without
> converting to some sort of char* - which I can't work out how to do !!
> (I did notice that the TCustomWinSocket has a method:
> int __fastcall ReceiveBuf(void *Buf, int Count);
> which is looks what I want to do to my raw socket, however I want to
> port the code over to UNIX at some point and guess I can't use this).
>
> any comments/suggestions on this issue would be gratefully recieved
I suggest you use TWSOcket component from the freeware ICS package. You'll
get full source code and compatibility withh *ALL* Delphi and C++Builder
versions. And if you don't wants to use the component, you can see how it
works as full source code is provided. Download from
http://www.rtfm.be/fpiette/indexuk.htm
--
francois.piette@pophost.eunet.be
The freeware Internet Component Suite maker
Download from http://www.rtfm.be/fpiette/indexuk.htm
Technical Details
Message-ID:
<01bda406$116a9a80$1f41a1c0@fpiette.chrlg.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3597BA2D.F6DFE3DB@stocktrade.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10fbec,30838b54da12b6ba X-Google-Attributes: gid10fbec,public X-Google-Thread: f973d,30838b54da12b6ba X-Google-Attributes: gidf973d,public X-Google-Thread: 10baee,30838b54da12b6ba X-Google-Attributes: gid10baee,public X-Google-Thread: f5ca7,30838b54da12b6ba X-Google-Attributes: gidf5ca7,public From: "Fran�ois Piette" <francois.piette@pophost.eunet.be> Subject: Re: C++/Delphi sockets question Date: 1998/06/30 Message-ID: <01bda406$116a9a80$1f41a1c0@fpiette.chrlg.be> X-Deja-AN: 367370310 References: <3597BA2D.F6DFE3DB@stocktrade.co.uk> Organization: C.H.R. de la Citadelle Newsgroups: comp.lang.pascal.delphi.misc,alt.lang.delphi,borland.public.cppbuilder.winapi,borland.public.cppbuilder.ide