Board index » delphi » TServerSocket & TClientSocket with user-defined records

TServerSocket & TClientSocket with user-defined records

I have a problem with TServerSocket and TClientSocket: The user can define
his own records and should be able to send these records over the net
client2server and server2client. I implemented everything and the client
receives already the stuff I send from the server but as soon as it has
received the program freezes. I upload the components and the demo in
b.p.attachments because it's hard to explain. Just try the example and
you'll see what I mean (hopefully).

Thanks in advance for all replies,
Helge.

P.S. I tried to do the whole thing with Indy but had some other problems so
I decided to switch back to TServerSocket and TClientSocket. If someone has
a running component with Indy I'd be glad if he or she could give me a look
at it's source to see how it works. Maybe I'm just overseeing something :-/

 

Re:TServerSocket & TClientSocket with user-defined records


"Helge Jung (ECO-Logic)" <he...@eco-logic-software.de> schreef in bericht
news:3c80edb9_1@dnews...

Quote
> I have a problem with TServerSocket and TClientSocket: The user can define
> his own records and should be able to send these records over the net
> client2server and server2client. I implemented everything and the client
> receives already the stuff I send from the server but as soon as it has
> received the program freezes.

[snip]

Hi Helge,

I have not studied your code in all detail, but since you say that the
program freezes when it gets data, this typecast seems _very suspect to me:

---
if Assigned (FOnReceived) then
    FOnReceived (Self, rCB, Pointer(@FData[0]));
---

Why not simply pass ( Self, Rcb, Fdata[0] ),
or  ( Self, Rcb, FData ) ??

( I'm assuming that rCB contains the actual length of FData )

--
Regards,

Dirk Claessens
---------------------------------------------------------
http://users.pandora.be/dirk.claessens2
Attention: All spamshields raised; E-mails will bounce!
---------------------------------------------------------

Re:TServerSocket & TClientSocket with user-defined records


Quote
> I have not studied your code in all detail, but since you say that the
> program freezes when it gets data, this typecast seems _very suspect to

me:

The problem is that I don't know what comes after my datablock. I know the
length of it but that's all. So I read everything in an array of byte.
Someone pointed me to use pointers to pass the variables because sending was
not the problem (procedure Send (var Data);) but receiving was. I don't know
how to pass the data so the user can map it into his own record. FData is an
array of byte whereas the parameter which shall be supplied is an pointer.
So your attempt will fail because I've tried at least the second one before
I came to my current "solution". The whole thing works - the data is
received and transmitted properly. But as soon as the data has been supplied
to the end user and he could do something with it, the client freezes (the
server keeps on running ,-).

I assume I'm just overseeing something but maybe someone does see that thing
and tells me *g*

But thanks for looking into my code,
Helge.

P.S. That "_very suspect" typecast is by Rudy Velthuis (TeamB) ... in
b.p.d.objectpascal: "Array problem" (24.2.'02)

Re:TServerSocket & TClientSocket with user-defined records


Hi,

Firstly I see you are using ReceiveLength. This value is unreliable and
should not be used. I have sent you a client/server example. This is an
example of uploading a file but also includes a record header.

Paul

"Helge Jung (ECO-Logic)" <he...@eco-logic-software.de> wrote in message
news:3c80edb9_1@dnews...

Quote
> I have a problem with TServerSocket and TClientSocket: The user can define
> his own records and should be able to send these records over the net
> client2server and server2client. I implemented everything and the client
> receives already the stuff I send from the server but as soon as it has
> received the program freezes. I upload the components and the demo in
> b.p.attachments because it's hard to explain. Just try the example and
> you'll see what I mean (hopefully).

> Thanks in advance for all replies,
> Helge.

> P.S. I tried to do the whole thing with Indy but had some other problems
so
> I decided to switch back to TServerSocket and TClientSocket. If someone
has
> a running component with Indy I'd be glad if he or she could give me a
look
> at it's source to see how it works. Maybe I'm just overseeing something
:-/

Other Threads