BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sending a record client/client via server
Goto page 1, 2, 3 ... 12, 13, 14  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
server
Guest





PostPosted: Fri Feb 03, 2006 4:47 pm    Post subject: Sending a record client/client via server Reply with quote



message unavailable
Back to top
Luka
Guest





PostPosted: Fri Feb 03, 2006 4:47 pm    Post subject: Re: Sending a record client/client via server Reply with quote



Quote:

Sorry, my mistake. There was an omission in the reading thread code. The
Execute() method should look like this:


It works now! but only for two clients. When the 3rd client connects to the
server, it executes IdTCPServerListenException and the MyData travels only
between two other clients. So, it works fine only for two first connected
clients. A few days ago in other post you said it doesn't matter how many
clients are connected, so I think there might be a mistake in procedure
below:


procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
var
Data: TMyData;
List: TList;
I: Integer;
LThread: TIdPeerThread;
begin
AThread.Connection.ReadBuffer(Data, SizeOf(Data));
List := AThread.Connection.Server.Threads.LockList;
try
for I := 0 to Pred(List.Count) do
begin
LThread := TIdPeerThread(List[I]);
if LThread <> AThread then
try
LThread.Connection.WriteBuffer(Data, SizeOf(Data));
except
end;
end;
finally
AThread.Connection.Server.Threads.UnlockList;
end;
end;
Back to top
Luka
Guest





PostPosted: Fri Feb 03, 2006 5:09 pm    Post subject: Re: Sending a record client/client via server Reply with quote



Użytkownik "Luka" <soonic (AT) op (DOT) plxx> napisał w wiadomości
news:43e34212 (AT) newsgroups (DOT) borland.com...
Quote:

Sorry, my mistake. There was an omission in the reading thread code.
The
Execute() method should look like this:


It works now! but only for two clients. When the 3rd client connects to
the

Thank you very much for your help, everything works fine I forgot that I had
set for Max 2 connections, that's why I had trouble with the 3rd client -
ehhh.... this is great it's working now!

I'm still thinking of making my server application also as client
application, so I would have run only one application in the taskbar instead
of two (the server and the client). If you think you have enough patience to
help me, then please try.

greetings
L.
Back to top
Luka
Guest





PostPosted: Fri Feb 03, 2006 7:05 pm    Post subject: Re: Sending a record client/client via server Reply with quote

Quote:
I'm still thinking of making my server application also as client
application, so I would have run only one application in the taskbar
instead of two (the server and the client). If you think you have enough
patience to

Well, that's my 3rd reply already (because of the time zone), during that
time I added to the server application also IdTCPClient component with the
Client's code, so the server works as a client and server at the same time.
I'm not sure if its good way to do it like that but I made some tests it
looks like it works fine.

Finally, would you have time to explain me in simple words line by line how
it works:

1) Why you suggested to change for Char? (probably it'd work with string
too)
type
TMyData = packed record
//a,b: string[10];
a: array[0..9] of Char;
b: array[0..9] of Char;
c:boolean;
end;

2) CLIENT
type
TReadingThread = class(TThread)
private
FData: TMyData;
FConn: TIdTCPConnection;
procedure UpdateGrid;
protected
--> procedure Execute; override;
public
--> constructor Create(AConn: TIdTCPConnection); reintroduce;
end;

var
--> ReadingThread: TReadingThread = nil;

-->constructor TReadingThread.Create(AConn: TIdTCPConnection);
begin
FConn := AConn;
inherited Create(False);
end;

-->procedure TReadingThread.Execute;
begin
while not Terminated do
begin
FConn.ReadBuffer(FData, SizeOf(FData));
if not Terminated then Synchronize(UpdateGrid);
end;
end;

3) SERVER
procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
var
Data: TMyData;
List: TList;
I: Integer;
LThread: TIdPeerThread;
begin
--> AThread.Connection.ReadBuffer(Data, SizeOf(Data));
--> List := AThread.Connection.Server.Threads.LockList;
try
--> for I := 0 to Pred(List.Count) do
begin
--> LThread := TIdPeerThread(List[I]);
--> if LThread <> AThread then
try
--> LThread.Connection.WriteBuffer(Data, SizeOf(Data));
except
end;
end;
finally
--> AThread.Connection.Server.Threads.UnlockList;
end;
end;
Back to top
Jacques
Guest





PostPosted: Sat Feb 04, 2006 12:51 am    Post subject: Re: SMTPserver problem - D7 indy10.0.52 Reply with quote

Well the i tested the smtpserver with an indy smtp client and it works fine,
there are no RSet' sent apart from the one somewhere near the beginning. So,
thanks alot for your help! As for the pop3 server, i am having the same sort
of problem where the message headers are not shown in the pop3client memo.
Here's the intercept info:

127.0.0.1:1946 Stat Connected.
127.0.0.1:1946 Sent 03/02/2006 19:20:49: +OK Welcome to Server<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:49: CAPA<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:49: +OK Capability list follows<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:49: UIDL<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:49: USER<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:49: .<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:49: USER xxxx<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:49: +OK Password required<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:49: PASS xxx<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:50: +OK Login OK<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:50: STAT<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:50: +OK 4 161<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:51: RETR 1<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: From: admin@localhost<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To: admin (AT) look (DOT) com<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Subject: hey there<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: <EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Body: This is the
body<EOL><EOL><EOL><EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: +OK<EOL>
127.0.0.1:1946 Recv 03/02/2006 19:20:51: RETR 2<EOL>RETR 3<EOL>RETR 4<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: From: luke (AT) loop (DOT) com<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To:
mess.Recipients.EMailAddresses<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Subject: mess.Subject<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: <EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Body: mess.Body.Text<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: +OK<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: From: jack (AT) loop (DOT) com<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To:
mess.Recipients.EMailAddresses<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Subject: mess.Subject<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: <EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Body: mess.Body.Text<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: +OK<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: From: cool (AT) look (DOT) com<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To:
mess.Recipients.EMailAddresses<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Subject: mess.Subject<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: <EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Body: mess.Body.Text<EOL>
127.0.0.1:1946 Sent 03/02/2006 19:20:51: +OK<EOL>

Which as you can see pretty much retrieves the msgs as it should, and it
does send them all to the requesting client,except, the client just does not
seem to recieve the headers or if it does, it does not show them in the memo
component. below is the client and server code:

Client
procedure TForm1.Button1Click(Sender: TObject);
var
intindex,I,n1,fmailboxsize,msgcount,k:integer;
li:tlistitem;
begin
if pop1.Connected then pop1.Disconnect;
//************** connect to server********************************
//Setup connection
pop1.Host:='localhost';
.....
pop1.Connect ;
msgcount:=pop1.CheckMessages;
showmessage(inttostr(msgcount));
if msgcount > 0 then
begin
for intindex := 1 to msgcount do
begin
pop1.Retrieve(intIndex, Mess);
memo1.Lines.Add(mess.Subject);<--THIS COMES UP EMPTY
end;
end;
end;

SERVER:
procedure TForm1.popsRetrieve(aCmd: TIdCommand; AMsgNo: Integer);
begin
//open table
ado1.Open;
//makes sure that amsgno is less than total number of records
if AMsgNo <= ado1.RecordCount then begin
//set tbl record to amsgno and retrieve the record
ado1.RecNo:=AMsgNo;
//send it off....
with aCmd.Context.Connection.IOHandler do
begin
Writeln('From: '+ado1.Fieldbyname('from').Text);
Writeln('To: '+ado1.Fieldbyname('to').text);
Writeln('Subject: '+ado1.Fieldbyname('subject').Text);
WriteLn;
Writeln('Body: '+ado1.Fieldbyname('mbody').text);
end; //with
end //amsgno reccount check

Thanks
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:43e15b15$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Jacques" <jacques.noah (AT) btinternet (DOT) com> wrote in message
news:43e1502c$1 (AT) newsgroups (DOT) borland.com...

I use telnet to test the server, and the intercept shows all
the commands that i'm using

Well, then why are YOU sending multiple RSET commands in the wrong places?

i've not tested it with anything else as yet.

Then I strongly suggest that you stop sending commands manually and use an
automated process instead. Indy does have an SMTP client component, it
would take only a moment to write a test app to connect to your server
with.


Gambit


Back to top
Riki Wiki
Guest





PostPosted: Sat Feb 04, 2006 2:10 am    Post subject: Re: Socks_Server and Socks_Info Reply with quote

Hoi Dmitry

You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question.

Take a look here:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups>
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 04, 2006 6:17 am    Post subject: Re: Sending a record client/client via server Reply with quote

"Luka" <soonic (AT) op (DOT) plxx> wrote in message
news:43e34212 (AT) newsgroups (DOT) borland.com...

Quote:
It works now! but only for two clients.

The code I have given you works fine for as many connections as the server
can accept.

Quote:
When the 3rd client connects to the server, it executes
IdTCPServerListenException

The only way that can happen is if an exception occurs while a new
connection is being accepted. About the way that should be happening is
when there are memory/resource problems on the machine at the time.

What is the actual class type of the exception, and its text? That will
tell you why the exception occured.

Quote:
A few days ago in other post you said it doesn't matter how
many clients are connected

That is correct.

Quote:
so I think there might be a mistake in procedure below:

There is no mistake in that code, and that code has no effect on the
server's ability to accept more connections.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 04, 2006 6:18 am    Post subject: Re: Sending a record client/client via server Reply with quote

"Luka" <soonic (AT) op (DOT) plxx> wrote in message
news:43e34721 (AT) newsgroups (DOT) borland.com...

Quote:
I'm still thinking of making my server application also as client
application,
so I would have run only one application in the taskbar instead of two
(the server and the client). If you think you have enough patience to help
me, then please try.

You already have enough working code for both sides to handle that yourself.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 04, 2006 6:25 am    Post subject: Re: Sending a record client/client via server Reply with quote

"Luka" <soonic (AT) op (DOT) plxx> wrote in message
news:43e36269 (AT) newsgroups (DOT) borland.com...

Quote:
1) Why you suggested to change for Char?

Because short strings have an extra byte at the beginning of the string data
that specifies the length of the data. Since you are already hard-coding
the size of the values, there is no need for the extra overhead.

Quote:
probably it'd work with string too

The code you have will NOT work as-is if you use long strings. That is
because the character data is stored elsewhere in memory. If you have a
record containing log strings, and you try to send that record as-is, you
will NOT be sending the characters at all. You would have to send the
string values separately, since you have to reference into the character
memory using the PChar() or '[]' operators to retreive the true starting
memory address of the characters.

Quote:
--> procedure Execute; override;
--> constructor Create(AConn: TIdTCPConnection); reintroduce;

What are you trying to ask?

Quote:
var
--> ReadingThread: TReadingThread = nil;

That is self-explanatory. TReadingThread is a class. The line is declaring
a variable of that class type which is then intiialized to nil.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Feb 04, 2006 6:51 am    Post subject: Re: SMTPserver problem - D7 indy10.0.52 Reply with quote

"Jacques" <jacques.noah (AT) btinternet (DOT) com> wrote in message
news:43e3b373 (AT) newsgroups (DOT) borland.com...

Quote:
Well the i tested the smtpserver with an indy smtp client and it
works fine, there are no RSet' sent apart from the one somewhere
near the beginning.

As it should be.

Quote:
As for the pop3 server, i am having the same sort of problem
where the message headers are not shown in the pop3client memo.

What does that code look like?

Quote:
Here's the intercept info:

That log is wrong, specifically, in this portion:

Quote:
127.0.0.1:1946 Recv 03/02/2006 19:20:51: RETR 1<EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: From: admin@localhost<EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To: admin (AT) look (DOT) com<EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Subject: hey there<EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: <EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: Body: This is the
body<EOL><EOL><EOL><EOL
127.0.0.1:1946 Sent 03/02/2006 19:20:51: +OK<EOL

The +OK response must be sent BEFORE sending the message data, not AFTER.
Also, there is no terminating "." at the end of the message data, either.

Quote:
127.0.0.1:1946 Recv 03/02/2006 19:20:51: RETR 2<EOL>RETR 3<EOL>RETR 4<EOL

The same errors as above.

Quote:
127.0.0.1:1946 Sent 03/02/2006 19:20:51: To:
mess.Recipients.EMailAddresses<EOL
snip


Is that what is actually being transmitted, or did you substitute the values
in the log manually?

Quote:
Which as you can see pretty much retrieves the msgs as it should, and it
does send them all to the requesting client

It is not sending the data correctly.

Quote:
below is the client and server code:

Your client code is fine. You server code is wrong.

Quote:
procedure TForm1.popsRetrieve(aCmd: TIdCommand; AMsgNo: Integer);

At no point in that code are you sending the +OK response before sending the
message data. As such, TIdCommand is sending the +OK response automatically
after the event handler exits, which is the wrong time to send it.

Try this code instead:

procedure TForm1.popsRetrieve(aCmd: TIdCommand; AMsgNo: Integer);
var
// using a TStringList so that Indy can automatically ensure
// that any lines beginning with '.' will not screw up the response
Data: TIdStringList;
begin
Data := TIdStringList.Create;
try
ado1.Open;

if (AMsgNo < 1) or (AMsgNo > ado1.RecordCount) then
raise Exception.Create('invalid message number');

ado1.RecNo := AMsgNo;

Data.Add('From: ' + ado1.FieldByName('from').Text);
Data.Add('To: ' + ado1.FieldByName('to').Text);
Data.Add('Subject: ' + ado1.FieldByName('subject').Text);
Data.Add('');
Data.Add(ado1.FieldByName('mbody').Text);

aCmd.Reply.SetReply(OK, 'message follows');
aCmd.SendReply; // <-- YOU MUST DO THIS BEFORE SENDING THE DATA

aCmd.Context.Connection.WriteRFCStrings(Data); // <-- INCLUDES
THE TERMINATING '.' LINE
finally
Sys.FreeAndNil(Data);
end;
end;


Gambit
Back to top
Luka
Guest





PostPosted: Sat Feb 04, 2006 4:02 pm    Post subject: Re: Sending a record client/client via server Reply with quote

Użytkownik "Luka" <xxsoonic (AT) op (DOT) pl> napisał w wiadomości
news:43e26775 (AT) newsgroups (DOT) borland.com...
Quote:
hi

I'm trying to send a record from 1 client to two other clients via a
server using Indy Components.

One more thing can you help me?
Regarding to the root post, I'd like to be able to send also TStream the
same way as other MyData( client-server-client).
There is a procedure in AdvStringGrid - SaveToBinStream and SaveToStream
(don't know which in this case will work better) and pressing a button I
tried in several ways to make it work but I can't.

1) Using
TMydata=packed record
...
d: Tmemorystream; -->???
end;

procedure TForm1.ButtonSendClick(Sender: TObject);
var
MyData: TMyData;
begin
if not IdTCPClient.Connected then Exit;
MyData.a := edit1.Text;

MyData.d := TMemoryStream.Create;
Grid.SaveToBinStream(MyData.d)
IdTCPClient.WriteBuffer(MyData, SizeOf(MyData));
end;

2) or IdTCPClient.WriteStream(....)

In one word except for other values (string, boolean) I'd like also update
my StringGrids on all clients using simply TStream.
-->SaveToBinStream-->send stream with IdTCP --> receive stream with
IdTCP -->>LoadFromBinStream
I'm thinking of using "IdTCPClient.WriteStream " but also I want to send
other types of MyData.
Can you help me to update the client/server code so far for sending TStream
as well?

regard
L.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Feb 07, 2006 9:02 pm    Post subject: Re: Sending a record client/client via server Reply with quote

"Luka" <soonic (AT) op (DOT) plxx> wrote in message
news:43e4c6e8 (AT) newsgroups (DOT) borland.com...

Quote:
Regarding to the root post, I'd like to be able to send also
TStream the same way as other MyData( client-server-client).

Indy has ReadStream() and WriteStream() methods for that.

Quote:
TMydata=packed record
...
d: Tmemorystream; -->???
end;

You cannot send records that have dynamically-allocated data in them. You
will have to send the dynamic data separately from the rest of the record
data. The same goes for all types of dynamic data (long strings, dynamic
arrays, etc) because the actual data is not stored in the record's memory
directly, it is stored in its own separate memory that the record points to.

Quote:
In one word except for other values (string, boolean) I'd like also update
my StringGrids on all clients using simply TStream.
-->SaveToBinStream-->send stream with IdTCP --> receive stream with
IdTCP -->>LoadFromBinStream
I'm thinking of using "IdTCPClient.WriteStream " but also I want to send
other types of MyData.
Can you help me to update the client/server code so far for sending
TStream
as well?

At this point, since you are mixing so many different types of data in your
record, I would suggest not using a record at all. Change it into a class
instead. Then the class that hide the details of how it reads/writes its
data. For example:

type
TMyData = class
public
a: String;
b: String;
c: Boolean;
d: TStream;
constructor Create;
destructor Destroy;
procedure ReadFrom(AConn: TIdTCPConnection);
procedure WriteTo(AConn: TIdTCPConnection);
end;

constructor TMyData.Create;
begin
d := TMemoryStream.Create;
end;

destructor TMyData.Destroy;
begin
d.Free;
end;

procedure TMyData.ReadFrom(AConn: TIdTCPConnection);
begin
d.Size := 0;
a := AConn.ReadString(AConn.ReadInteger);
b := AConn.ReadString(AConn.ReadInteger);
AConn.ReadBuffer(@c, SizeOf(Boolean));
AConn.ReadStream(d, -1, False);
d.Position := 0;
end;

procedure TMyData.WriteTo(AConn: TIdTCPConnection);
var
procedure WriteString(const S: String);
var
L: Integer;
begin
L := Length(S);
AConn.WriteInteger(L);
if L > 0 then AConn.WriteBuffer(PChar(S), L);
end;
begin
WriteString(a);
WriteString(b);
AConn.WriteBuffer(@c, SizeOf(Boolean));
AConn.WriteStream(d, True, True, 0);
end;


Then you can do the following:

--- client ---

type
TReadingThread = class(TThread)
private
FData: TMyData;
FConn: TIdTCPConnection;
procedure UpdateGrid;
protected
procedure Execute; override;
public
constructor Create(AConn: TIdTCPConnection); reintroduce;
destructor Destroy; override;
end;

constructor TReadingThread.Create(AConn: TIdTCPConnection);
begin
FConn := AConn;
FData := TMyData.Create;
inherited Create(False);
end;

destructor TReadingThread.Destroy;
begin
FData.Destroy;
inherited Destroy;
end;

procedure TReadingThread.Execute;
begin
while not Terminated do
begin
FData.ReadFrom(FConn);
if not Terminated then Synchronize(UpdateGrid);
end;
end;

procedure TReadingThread.UpdateGrid;
begin
Form1.Edit1.Text := FData.a;
Form1.Edit6.Text := FData.b;
Form1.CheckBox1.Checked := FData.c;
Form1.Grid.LoadFromBinStream(MyData.d);
end;

procedure TForm1.ButtonSendClick(Sender: TObject);
var
MyData: TMyData;
begin
if not IdTCPClient.Connected then Exit;
MyData := TMyData.Create;
try
MyData.a := Edit1.Text;
MyData.b := Edit6.Text;
MyData.c := CheckBox1.Checked;
Grid.SaveToBinStream(MyData.d);
MyData.WriteTo(IdTCPClient);
finally
MyData.Free;
end;
end;

--- server ---

procedure TForm1.IdTCPServerExecute(AThread: TIdPeerThread);
var
Data: TMyData;
List: TList;
I: Integer;
LThread: TIdPeerThread;
begin
Data := TMyData.Create;
try
Data.ReadFrom(AThread.Connection);
List := IdTCPServer.Threads.LockList;
try
for I := 0 to Pred(List.Count) do
begin
LThread := TIdPeerThread(List[I]);
if LThread <> AThread then
try
Data.WriteTo(LThread.Connection);
except
end;
end;
finally
IdTCPServer.Threads.UnlockList;
end;
finally
Data.Destroy;
end;
end;


Gambit
Back to top
Luka
Guest





PostPosted: Tue Feb 07, 2006 11:02 pm    Post subject: Re: Sending a record client/client via server Reply with quote

Quote:
procedure TMyData.ReadFrom(AConn: TIdTCPConnection);
begin
d.Size := 0;
a := AConn.ReadString(AConn.ReadInteger);
b := AConn.ReadString(AConn.ReadInteger);
AConn.ReadBuffer(@c, SizeOf(Boolean));
AConn.ReadStream(d, -1, False);
d.Position := 0;
end;

AConn.ReadBuffer(@c, SizeOf(Boolean));

I get warrning and error:
1) Unsafe code '@ operator'
2) Constant object cannot be passed as var parameter

How to interpret them and change?



Quote:
procedure TReadingThread.UpdateGrid;
begin
Form1.Edit1.Text := FData.a;
Form1.Edit6.Text := FData.b;
Form1.CheckBox1.Checked := FData.c;
Form1.Grid.LoadFromBinStream(MyData.d);
^^^

I think it should be FData.d ?

And finally if I cut everywhere boolean variable then I get one more error

Quote:
procedure TMyData.WriteTo(AConn: TIdTCPConnection);
var
procedure WriteString(const S: String);
var
L: Integer;
begin
L := Length(S);
AConn.WriteInteger(L);
if L > 0 then AConn.WriteBuffer(PChar(S), L);

^
Error: Variable required

Quote:
end;
begin
WriteString(a);
WriteString(b);
// AConn.WriteBuffer(@c, SizeOf(Boolean));
AConn.WriteStream(d, True, True, 0);
end;
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Feb 08, 2006 12:04 am    Post subject: Re: Sending a record client/client via server Reply with quote

"Luka" <soonic (AT) op (DOT) plxx> wrote in message
news:43e90754 (AT) newsgroups (DOT) borland.com...

Quote:
AConn.ReadBuffer(@c, SizeOf(Boolean));

I get warrning and error:
1) Unsafe code '@ operator'

Which version of Delphi are you using? At the very least, try taking out
the @ then:

AConn.ReadBuffer(c, SizeOf(Boolean));

Quote:
Form1.Grid.LoadFromBinStream(MyData.d);
^^^
I think it should be FData.d ?

Yes.

Quote:
And finally if I cut everywhere boolean variable

I do not understand what you are referring to.

Quote:
then I get one more error

if L > 0 then AConn.WriteBuffer(PChar(S), L);

^
Error: Variable required

You can change that to this:

AConn.Write(S);

Quote:
// AConn.WriteBuffer(@c, SizeOf(Boolean));

If you comment that out, the boolean will not be sent If the receiver tries
to continue read it, then the stream will be corrupted.


Gambit
Back to top
Luka
Guest





PostPosted: Wed Feb 08, 2006 8:02 am    Post subject: Re: Sending a record client/client via server Reply with quote

Quote:

Which version of Delphi are you using? At the very least, try taking out
the @ then:

Delphi 7.


Quote:
AConn.ReadBuffer(c, SizeOf(Boolean));

And finally if I cut everywhere boolean variable

I do not understand what you are referring to.


Because I got error in Boolean line, I wanted not to include Boolean in my
project to see if I'll be able to compile, but then another error appeared
with AConn.WriteBuffer(....).

Well, I made changes as you said, and all seems to be working fine. You're
genius comparing to my skill level in programming. Thank you very much for
all your help. No more questions to this topic (at the moment Smile - I hope I
can finish now my application.


Lukasz
Back to top
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Goto page 1, 2, 3 ... 12, 13, 14  Next
Page 1 of 14

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.