Re: [twsocket] SslWSocketServer SslWSocket

2011-01-18 Thread daniel cc

Hi Marc,
Your code works perfectly :)
It created the UniqueID for the client and I believe this just was what I 
needed. Now I will be able to select the client of my choice with this ID.

I will do the rest and start testing.

Thanks a lot for the great help :)

Best regards

-Original Message- 
From: Marc Charbonneau

Sent: Tuesday, January 18, 2011 3:58 PM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer  SslWSocket


Thanks Marc,
Have been playing 2 days with this and still can't find out the way how 
to

do.


Ok, here's a simple solution with TcpSrv demo :

In TTcpSrvForm declaration, in the private part, add this

   FClientNo : integer;

Now, go in procedure TTcpSrvForm.WSocketServer1ClientConnect and
change the code to look like this :
procedure TTcpSrvForm.WSocketServer1ClientConnect(
   Sender : TObject;
   Client : TWSocketClient;
   Error  : Word);
begin
   with Client as TTcpSrvClient do begin
   Inc(FClientNo); // Increment unique client no
   Tag := FClientNo; // tag connecting client with it's id
   Display('Client connected. UniqueID : ' + IntToStr(Tag) +
   ' Remote: ' + PeerAddr + '/' + PeerPort +
   ' Local: '  + GetXAddr + '/' + GetXPort);
   Display('There is now ' +
   IntToStr(TWSocketServer(Sender).ClientCount) +
   ' clients connected.');
   LineMode:= TRUE;
   LineEdit:= TRUE;
   LineLimit   := 80; { Do not accept long lines }
   OnDataAvailable := ClientDataAvailable;
   OnLineLimitExceeded := ClientLineLimitExceeded;
   OnBgException   := ClientBgException;
   ConnectTime := Now;
   end;
end;

Now, change your SendCommand procedure to something like this :

procedure TTcpSrvForm.SendCommand(ClientNo: integer; CommandText: string);
var
 i: integer;
begin
for i := 0 to WSocketServer1.ClientCount -1 do
begin
 // iterate all client trying to find the right one
  if WSocketServer1.Client[i].Tag = ClientNo then
  begin
WSocketServer1.Client[i].SendStr(CommandText);
Display('Command sent: ' + CommandText);
   break;
  end;
end;
end;

This should do what you want.

hope this help

Marc
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc



-Original Message- 
From: Francois PIETTE

Sent: Monday, January 17, 2011 9:33 AM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer  SslWSocket


and it doesn't work


Please be more specific. What error/exception do you have ?




Hi Francois,
Thanks for the response and being pation.

I have checked in the project the -- OnDataAvailable as you adviced and it 
is absolutely same as what I also have.


What I am trying to do is,
Server is on and running, client is connected and I have the info on 
Display which says about what client is connected etc.


Now,
How can I selected a specific client, let's say client 1 and send a command 
to it?


Here is what I am trying,

SslWSocketServer1.(Sender).Send(MyBufAddr, MyBufLnegth); -- need to be able 
to send the command which is typed in the TEdit field and I have no idea 
about how this works, so far I don't even know how to handle -- (MyBufAddr, 
MyBufLnegth);  either.


After sending the command to the client,
Display('Command sent: ' + ledSendCommand.Text); -- ledSendCommand is a 
TLabelEdit


-daniel 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE

and it doesn't work

Please be more specific. What error/exception do you have ?


You have not answered this one.

How can I selected a specific client, let's say client 1 and send a 
command to it?


Speaking about code, you select it by its index in the Client[] property.
How you find the right index is YOUR application problem. Tell me in english 
how you would like to select one client among all the connected clients and 
I will help you translate this specification to code.


But, are you sure you don't want to revert the client/server roles ?
It would be much simpler for you.

If the side you name server has to send commands to the side you name 
client for execution and get back results, then what you name server is 
actually a socket client and what you name client is actually a socket 
server.


To say it otherwise: There is no problem having the computer you name 
server to be an actual client - as far as socket programming is 
concerned - for the computer you name as client which is turn would be a 
server as far as socket programming is concerned.


You may also have both client and server socket at both side. By the way, 
this is how FTP is working: the FTP client connect to the FTP server to send 
commands (file transfert, dir list,...) to be executed by the server. When 
the FTP server has to transfert a file, the (FTP) server become a (socket) 
client connecting to a (server) socket located at the (FTP) client ! This 
could be a scheme you could use to design your application.



SslWSocketServer1.(Sender).Send(MyBufAddr, MyBufLnegth); -- need to be 
able to send the command which is typed in the TEdit field and I have no 
idea about how this works, so far I don't even know how to handle -- 
(MyBufAddr, MyBufLnegth);  either.


Excuse me, don't take it worng, but I'm wondering if you know Delphi 
programming or not :-(
You can see in the component source code and in the samples that Send method 
takes two arguments, the first is a pointer to what you want to send and the 
second is the number of bytes to send. You have a lot of ways to use that in 
your software ! If you only have text to send, probably SendStr() method 
will be easier for you: it take a single string type argument. Look at the 
implementation to learn how SendStr() call Send()...


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: daniel cc dan...@signedsource.com

To: ICS support mailing twsocket@elists.org
Sent: Monday, January 17, 2011 9:15 AM
Subject: Re: [twsocket] SslWSocketServer  SslWSocket





-Original Message- 
From: Francois PIETTE

Sent: Monday, January 17, 2011 9:33 AM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer  SslWSocket


and it doesn't work


Please be more specific. What error/exception do you have ?




Hi Francois,
Thanks for the response and being pation.

I have checked in the project the -- OnDataAvailable as you adviced and 
it is absolutely same as what I also have.


What I am trying to do is,
Server is on and running, client is connected and I have the info on 
Display which says about what client is connected etc.


Now,
How can I selected a specific client, let's say client 1 and send a 
command to it?


Here is what I am trying,

SslWSocketServer1.(Sender).Send(MyBufAddr, MyBufLnegth); -- need to be 
able to send the command which is typed in the TEdit field and I have no 
idea about how this works, so far I don't even know how to handle -- 
(MyBufAddr, MyBufLnegth);  either.


After sending the command to the client,
Display('Command sent: ' + ledSendCommand.Text); -- ledSendCommand is a 
TLabelEdit


-daniel
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

and it doesn't work

Please be more specific. What error/exception do you have ?


You have not answered this one.



Most of the errors were -- Socket not connected.


Speaking about code, you select it by its index in the Client[] property.
How you find the right index is YOUR application problem. Tell me in english
how you would like to select one client among all the connected clients and
I will help you translate this specification to code.



Here is what need to do,
When the client is connected,
It informs it's IP and connection port to the server as this: Client 
connected. Remote: 127.0.0.1/51665 Local: 127.0.0.1/443
I need to be able to use this information or ar least some of this 
information to send some commands this client.


But, are you sure you don't want to revert the client/server roles ?
It would be much simpler for you.


I am sorry but I don't understand what you mean with this, Windows 
server/client rules or component?


If the side you name server has to send commands to the side you name
client for execution and get back results, then what you name server is
actually a socket client and what you name client is actually a socket
server.

To say it otherwise: There is no problem having the computer you name
server to be an actual client - as far as socket programming is
concerned - for the computer you name as client which is turn would be a
server as far as socket programming is concerned.

You may also have both client and server socket at both side. By the way,
this is how FTP is working: the FTP client connect to the FTP server to send
commands (file transfert, dir list,...) to be executed by the server. When
the FTP server has to transfert a file, the (FTP) server become a (socket)
client connecting to a (server) socket located at the (FTP) client ! This
could be a scheme you could use to design your application.



Do you think I need both in both sides?
If yes,
Is it going to make any easier for me?
I need to start with sending commands but I need to send and receive files 
also in feature.




SslWSocketServer1.(Sender).Send(MyBufAddr, MyBufLnegth); -- need to be 
able to send the command which is typed in the TEdit field and I have no 
idea about how this works, so far I don't even know how to handle -- 
(MyBufAddr, MyBufLnegth);  either.


Excuse me, don't take it worng, but I'm wondering if you know Delphi
programming or not :-(
You can see in the component source code and in the samples that Send method
takes two arguments, the first is a pointer to what you want to send and the
second is the number of bytes to send. You have a lot of ways to use that in
your software ! If you only have text to send, probably SendStr() method
will be easier for you: it take a single string type argument. Look at the
implementation to learn how SendStr() call Send()...



Sorry again for not being able to explain clearly,
There is,
.Send
.SendSTR
.SendLine

My problem is,
What is the right way and how can I get the result I need?

Best regards 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE

But, are you sure you don't want to revert the client/server roles ?
It would be much simpler for you.


I am sorry but I don't understand what you mean with this, Windows 
server/client rules or component?

Do you think I need both in both sides?


Here is how I see your problem solved:
First let agree on terminology. I need 4 names: master, remote, client and 
server.
I will name remote computer or simply remote the group of computers you 
currently name client. I will name master computer or simply master 
the computer you actually name server.
I will name server socket or simply server a socket which passively wait 
(listen) for incomming connections.
I will name client socket or simply client a socket which will do 
whatever is needed to establish a connection.


Here are a few consequences:
Client socket will connect to server socket.
A socket server may have a lot of client connected.
Remote computer can have either or both client and server socket.
Master computer can have either or both client and server socket.

Here is how the whole application, distributed between remote (several) and 
master (only one) comoputer would operate.
The master computer shall have a single server socket waiting (listening) 
for remote computer connections.
A remote computer (there are a lot of them) shall connect to the master 
computer using a client socket.
A remote computer shall send commands to the master. Basically there are two 
commands: subscribe and unsubscribe.
Master computer receiving the subscribe command will add the remote computer 
in a list of remote computers participating in the work. Wehn receiving the 
unsubscribe command, the master computer will remove a remote computer from 
the list.
The master computer, having the list of all participating remote computers 
will be able to send commands to each remote computer. To do so, the master 
computer shall use a client socket to connect to the server socket listening 
at remote computer side. Obviously, each remote computer has a server socket 
waiting for connections and commands from the master they subscribed. That 
socket is programmed to accept only connections from the master after 
subscriuption take place.
Remote computer receiving commands from master computer will execute the 
command and return result back to the master computer.


This is a general picture of your software as I see it. Many details remains 
to be fixed but you get the general ideas.
Other solutions are obviously possible, including using server socket only 
at master side.


I can develop a specific set of demo programs for you, but not for free. 
Contact me by email if you want an offer.


Regards,
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: daniel cc dan...@signedsource.com

To: ICS support mailing twsocket@elists.org
Sent: Monday, January 17, 2011 11:03 AM
Subject: Re: [twsocket] SslWSocketServer  SslWSocket



and it doesn't work

Please be more specific. What error/exception do you have ?


You have not answered this one.



Most of the errors were -- Socket not connected.


Speaking about code, you select it by its index in the Client[] property.
How you find the right index is YOUR application problem. Tell me in 
english
how you would like to select one client among all the connected clients 
and

I will help you translate this specification to code.



Here is what need to do,
When the client is connected,
It informs it's IP and connection port to the server as this: Client 
connected. Remote: 127.0.0.1/51665 Local: 127.0.0.1/443
I need to be able to use this information or ar least some of this 
information to send some commands this client.


But, are you sure you don't want to revert the client/server roles ?
It would be much simpler for you.


I am sorry but I don't understand what you mean with this, Windows 
server/client rules or component?


If the side you name server has to send commands to the side you name
client for execution and get back results, then what you name server 
is

actually a socket client and what you name client is actually a socket
server.

To say it otherwise: There is no problem having the computer you name
server to be an actual client - as far as socket programming is
concerned - for the computer you name as client which is turn would be a
server as far as socket programming is concerned.

You may also have both client and server socket at both side. By the way,
this is how FTP is working: the FTP client connect to the FTP server to 
send

commands (file transfert, dir list,...) to be executed by the server. When
the FTP server has to transfert a file, the (FTP) server become a (socket)
client connecting to a (server) socket located at the (FTP) client ! This
could be a scheme you could use to design your application.



Do you think I need both in both sides?
If yes

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Angus Robertson - Magenta Systems Ltd
 Other solutions are obviously possible, including using server 
 socket only at master side.

My application only used a server at the master side, albeit three for
redundnacy, so the clients only contacted the servers to report status
and pick-up waiting commands.  Actually, this was partially true, there
was an emergency server in the client PCs in case something went wrong. 

But there were also UDP broadcasts from the servers every 30 seconds, if
they wanted the clients to call home more urgently.  These packets also
served to confirm that networking was all OK for the clients. 

Some of this depends on the session duration strategy, whether clients
contact the servers say once a minute or every five minutes or something,
or if they leave the connection open continually.  

Short sessions are better for resources, fewer connections, but is
horrible for SSL due to the massive overhead establishing a session and
checking certificates.  This is probably why Arno suggested not using SSL
but just data packet encryption.  

Permanent sessions solve the connection overhead and allow easy commands
from the server, but may cause resource problems on the servers, routers
and firewalls, and there are stale session issues if the client
disappears unexpectedly such as with wireless LANs where you need
timeouts and keep alive packets.  

As we have all said repeatedly, SSL is a minor issue compared to other
design concepts and should be left until a lot of other issues are
resolved. 

Also, sending file using a private protocol is simply re-inventing FTP
and will add substantially to project cost and timetable.  It may be OK
for the odd short file, but anything more complicated should use FTP.  My
project was the reason I spent a lot of time in the few years improving
FTP and adding many new FTP commands.   

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Guys,

Looks like nothing is possible to do in the simple and basic ways with ICS??

I was just thinking that I have understood a bit of the components today and 
now you guys are making it lot more complicated for me.


All I need is,
A server who accepts the clients and tells me which clients are online, can 
send once a while a simple command such as: reboot or send a file such as: 
setup.exe
A client who accepts  the command: reboot from the server and does the 
asked, receives the file setup.exe and does the asked.

The server will have maximum of 200 clients nothing more.

Sounds simple?
I can do this in 2 hours with TCUSTOMSOCKET of Delphi and protect it with 
SSH tunnel.

Why don't I?
Simple: because I want to do it with SSL in order to be able to have the 
better security, to have it in whole one piece and that is also the reason 
why I am not interested of doing it with the regular components because I 
can't secure them, because I don't have the knowledge of securing them.


Now,
Could you please answer,
can this be done with ICS or not?
if yes,
can you help me with the following procedure?
-
{This procedure sends the command to the clients and it works very nicely.}
procedure TSimpleSslServerForm.SendCommand;
begin
 SslWSocketServer1.Client[0].SendStr(ledSendCommand.Text); /// The PROBLEM 
here is: How do I send the command to a specific client if I have more than 
one client?

 Display('Command sent: ' + ledSendCommand.Text);
end;
--

Thanks in advance

-daniel


-Original Message- 
From: Francois PIETTE

Sent: Monday, January 17, 2011 3:55 PM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer  SslWSocket


But, are you sure you don't want to revert the client/server roles ?
It would be much simpler for you.


I am sorry but I don't understand what you mean with this, Windows 
server/client rules or component?

Do you think I need both in both sides?


Here is how I see your problem solved:
First let agree on terminology. I need 4 names: master, remote, client and
server.
I will name remote computer or simply remote the group of computers you
currently name client. I will name master computer or simply master
the computer you actually name server.
I will name server socket or simply server a socket which passively wait
(listen) for incomming connections.
I will name client socket or simply client a socket which will do
whatever is needed to establish a connection.

Here are a few consequences:
Client socket will connect to server socket.
A socket server may have a lot of client connected.
Remote computer can have either or both client and server socket.
Master computer can have either or both client and server socket.

Here is how the whole application, distributed between remote (several) and
master (only one) comoputer would operate.
The master computer shall have a single server socket waiting (listening)
for remote computer connections.
A remote computer (there are a lot of them) shall connect to the master
computer using a client socket.
A remote computer shall send commands to the master. Basically there are two
commands: subscribe and unsubscribe.
Master computer receiving the subscribe command will add the remote computer
in a list of remote computers participating in the work. Wehn receiving the
unsubscribe command, the master computer will remove a remote computer from
the list.
The master computer, having the list of all participating remote computers
will be able to send commands to each remote computer. To do so, the master
computer shall use a client socket to connect to the server socket listening
at remote computer side. Obviously, each remote computer has a server socket
waiting for connections and commands from the master they subscribed. That
socket is programmed to accept only connections from the master after
subscriuption take place.
Remote computer receiving commands from master computer will execute the
command and return result back to the master computer.

This is a general picture of your software as I see it. Many details remains
to be fixed but you get the general ideas.
Other solutions are obviously possible, including using server socket only
at master side.

I can develop a specific set of demo programs for you, but not for free.
Contact me by email if you want an offer.

Regards,
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: daniel cc dan...@signedsource.com

To: ICS support mailing twsocket@elists.org
Sent: Monday, January 17, 2011 11:03 AM
Subject: Re: [twsocket] SslWSocketServer  SslWSocket



and it doesn't work

Please be more specific. What error/exception do you have

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Angus Robertson - Magenta Systems Ltd
 A server who accepts the clients and tells me which clients are 
 online, can send once a while a simple command such as: reboot or 
 send a file such as: setup.exe
 A client who accepts  the command: reboot from the server and 
 does the asked, receives the file setup.exe and does the asked.
 The server will have maximum of 200 clients nothing more.
 
 Sounds simple?
 I can do this in 2 hours with TCUSTOMSOCKET of Delphi and protect 
 it with SSH tunnel.
 Could you please answer,
 can this be done with ICS or not?

If you think you can write and test the project in two hours with that
Delphi component, just go and do it. 

A lot of people here are spending a lot of time trying to help you, for
free, whether you wish to listen to our advice or not is your choice.  

All the code you need is in the samples, and protocols like FTP client
and server, you just need to spend some time looking at the code and
understanding it. 

I did it, numerous other people have done it, you can do it, but not in
two hours. 

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE
Looks like nothing is possible to do in the simple and basic ways with 
ICS??


Wrong impression.


All I need is,
A server who accepts the clients and tells me which clients are online, 
can send once a while a simple command such as: reboot or send a file 
such as: setup.exe
A client who accepts  the command: reboot from the server and does the 
asked, receives the file setup.exe and does the asked.

The server will have maximum of 200 clients nothing more.


Have a look at TnSrv sample. It open a new form for each client and you are 
trhen able to use that form to send text to the client. TnSrv is closer to 
what you want to do but IMO do not represent the best way to program with 
ICS.



Could you please answer,
can this be done with ICS or not?


Yes it can.


if yes,
can you help me with the following procedure?
{This procedure sends the command to the clients and it works very 
nicely.}

procedure TSimpleSslServerForm.SendCommand;
begin
 SslWSocketServer1.Client[0].SendStr(ledSendCommand.Text); /// The PROBLEM 
here is: How do I send the command to a specific client if I have more 
than one client?

 Display('Command sent: ' + ledSendCommand.Text);
end;


You can iterate thru Client[] array to find a client with the properties you 
need. You have direct access to IP and Port (look properties with peer in 
their name). And you can add any properties you like by deriving a new class 
and assigning it to TWSocketServer.ClientClass.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Angus,
Thanks for the response,

I am very pleased with all the help I have got here and I do love ICS 
components.

I wouldn't be trying do do anything with them would I?
If I wouldn't be happy with the components and with the help.

What I need here is some easy basic things not complecated ones.
I have been studying the components for about a week now and I already can 
do many things with them.


So,
My questions still remains,
can I do what I need with ICS?

Yes I can do with Delphi's TCUSTOMSOCKET because I already have an 
appliccation which does many things in my LAN environment (it is server and 
client based as well).

But,
I don't think it is as good as ICS and that is the reason why I would like 
to be able to understand and do things with ICS.


All I am trying to do with ICS right now is a simple demo for testing and to 
see how things are going to work and I believe that shouldn't take more than 
a week to achive.


I have been checking all the demos and trying to understand about how to 
send a Command to a specific client and I simply can't find it!
There are too many projects where the things are handled differently in each 
of them and none sends commands to the server.


I have made this test procedure which works but only if there is just one 
client.

-
{This procedure sends the command to the clients and it works very nicely.}
procedure TSimpleSslServerForm.SendCommand;
begin
 SslWSocketServer1.Client[0].SendStr(ledSendCommand.Text); /// The PROBLEM
here is: How do I send the command to a specific client if I have more than
one client?
 Display('Command sent: ' + ledSendCommand.Text);
end;
-




A server who accepts the clients and tells me which clients are
online, can send once a while a simple command such as: reboot or
send a file such as: setup.exe
A client who accepts  the command: reboot from the server and
does the asked, receives the file setup.exe and does the asked.
The server will have maximum of 200 clients nothing more.

Sounds simple?
I can do this in 2 hours with TCUSTOMSOCKET of Delphi and protect
it with SSH tunnel.
Could you please answer,
can this be done with ICS or not?


If you think you can write and test the project in two hours with that
Delphi component, just go and do it.

A lot of people here are spending a lot of time trying to help you, for
free, whether you wish to listen to our advice or not is your choice.

All the code you need is in the samples, and protocols like FTP client
and server, you just need to spend some time looking at the code and
understanding it.

I did it, numerous other people have done it, you can do it, but not in
two hours.

Angus


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE
I have been checking all the demos and trying to understand about how to 
send a Command to a specific client and I simply can't find it!


You found it because you told us:

I have made this test procedure which works but only if there is just one 
client.


{This procedure sends the command to the clients and it works very 
nicely.}

procedure TSimpleSslServerForm.SendCommand;
begin
 SslWSocketServer1.Client[0].SendStr(ledSendCommand.Text); /// The PROBLEM
here is: How do I send the command to a specific client if I have more 
than

one client?
 Display('Command sent: ' + ledSendCommand.Text);
end;


Your problem is not how to send to a given client, you've done that with the 
first client (index is 0) and it is the same for any other client, just 
change the index.


Your problem is at the application level: How do I select the right client ? 
Said in other word: How do I find the index to use with Client[] property ?

We cannot answer that question for you because we don't know the criteria !
You can create a form to ask the user which IP the client has and then 
iterate thru Client[] array and look for the correct IP.
Or you can show the list of clients on screen (again by iterating thru 
Client[] array) and let the user select the one he wants.


Do you understand what I mean ?

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Marc Charbonneau
 I have made this test procedure which works but only if there is just one
 client.
 -
 {This procedure sends the command to the clients and it works very nicely.}
 procedure TSimpleSslServerForm.SendCommand;
 begin
  SslWSocketServer1.Client[0].SendStr(ledSendCommand.Text); /// The PROBLEM
 here is: How do I send the command to a specific client if I have more than
 one client?
  Display('Command sent: ' + ledSendCommand.Text);
 end;
 -
SslWSocketServer1.Client is an array of your clients.
So if you have 2 clients, the first one is Client[0] and the second
one is Client[1].
If you have a third client then he's at Client[2].

I think you get the picture

so change your procedure to something like this :
procedure TSimpleSslServerForm.SendCommand(ClientNo: integer);
begin
 SslWSocketServer1.Client[ClientNo].SendStr(ledSendCommand.Text);
 Display('Command sent: ' + ledSendCommand.Text);
end;

The number of connected client is available in TWSocketServer.ClientCount

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Said in other word: How do I find the index to use with Client[] property ?
We cannot answer that question for you because we don't know the criteria !
You can create a form to ask the user which IP the client has and then
iterate thru Client[] array and look for the correct IP.



Yes,
This is what I need and Iam trying to send command to the client by using 
it's IP
As I can see here (OnProcessData) that I am getting the IP -- 
Client.SendStr(AClient.PeerAddr + ':' + AClient.GetPeerPort + ' ' +

but,
I don't know how to do this, and that is what I have been looking in the 
demos to find today.






Yes,
I do understand :)

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

-

SslWSocketServer1.Client is an array of your clients.
So if you have 2 clients, the first one is Client[0] and the second
one is Client[1].
If you have a third client then he's at Client[2].

I think you get the picture



Yes,
I get the picture.

so change your procedure to something like this :
procedure TSimpleSslServerForm.SendCommand(ClientNo: integer);
begin
SslWSocketServer1.Client[ClientNo].SendStr(ledSendCommand.Text);
Display('Command sent: ' + ledSendCommand.Text);
end;



How do you set this -- (ClientNo)?
How do you get the number in here?

Can you please explain a bit? 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Arno Garrels
daniel cc wrote:
 -
 SslWSocketServer1.Client is an array of your clients.
 So if you have 2 clients, the first one is Client[0] and the second
 one is Client[1].
 If you have a third client then he's at Client[2].
 
 I think you get the picture
 
 Yes,
 I get the picture.
 
 so change your procedure to something like this :
 procedure TSimpleSslServerForm.SendCommand(ClientNo: integer);
 begin
 SslWSocketServer1.Client[ClientNo].SendStr(ledSendCommand.Text);
 Display('Command sent: ' + ledSendCommand.Text);
 end;
 
 How do you set this -- (ClientNo)?
 How do you get the number in here?
 
 Can you please explain a bit?

What is so difficult? Property Client is an array of currently
connected client objects, property ClientCount returns the number 
of objects in that array. You work with it like with a standard 
Delphi TList as well. For example, in order to iterate over all
client objects:

var
  Cli: TWSocketClient;
begin
  for i := 0 to WSocketServer1.ClientCount -1 do
  begin  
Cli := WSocketServer1.Client[i];
if Cli meets some condition here then
  Call some Cli.method; 
  end;
end;

However usually a protocol follows the request/response pattern.
That is client requests something and server responds to that
client request, usually there's no need to iterate over the client
list or to search for a particular client object.

-- 
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Marc Charbonneau
 so change your procedure to something like this :
 procedure TSimpleSslServerForm.SendCommand(ClientNo: integer);
 begin
 SslWSocketServer1.Client[ClientNo].SendStr(ledSendCommand.Text);
 Display('Command sent: ' + ledSendCommand.Text);
 end;

 How do you set this -- (ClientNo)?
 How do you get the number in here?

 Can you please explain a bit?

Well, without knowing more on your setup, one way I can see to
differentiate your clients is with their IP. The client IP is
available in Client[x].PeerAddr.

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc


What is so difficult? Property Client is an array of currently
connected client objects, property ClientCount returns the number
of objects in that array. You work with it like with a standard
Delphi TList as well. For example, in order to iterate over all
client objects:


The difficulty is that I am quite lost with this and can't find a way of 
sending command to the client of my choice.


var
 Cli: TWSocketClient;
begin
 for i := 0 to WSocketServer1.ClientCount -1 do
 begin
   Cli := WSocketServer1.Client[i];
   if Cli meets some condition here then
 Call some Cli.method;
 end;
end;



Where do I call this exactly?

During the send? or receive?
Or a spearate procedure? how?

The problem here is,
You guys are treating me like an expert and I just don't understand half of 
the things what you are saying.



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc


Well, without knowing more on your setup, one way I can see to
differentiate your clients is with their IP. The client IP is
available in Client[x].PeerAddr.



My setup?
I am working on a demo,
I have memo field where I need to see the number of the client.

If I can get the number of the client than I will be able to do the rest.

Could you please help me out to get the client number into that memo?

I hope this help.
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Marc Charbonneau
On Mon, Jan 17, 2011 at 2:26 PM, daniel cc dan...@signedsource.com wrote:

 Well, without knowing more on your setup, one way I can see to
 differentiate your clients is with their IP. The client IP is
 available in Client[x].PeerAddr.

 My setup?
 I am working on a demo,
 I have memo field where I need to see the number of the client.
Which client ? Like I said, if you have only 1 client, his number will
be 0. If you have more than 1 client, then client 2 will be number 1
since Delphi use 0-based array.

How do you differentiate your clients ?

The server socket will just add all connecting client to the Client
array. You have to know which one is which.

If you only want to send commands to all connected clients, just
iterate over all your clients (like Arno told you) and send the
command to each one.

 If I can get the number of the client than I will be able to do the rest.

 Could you please help me out to get the client number into that memo?

That's what I and others are trying to do.

BTW, I'm not currently using ICS for anything, but I've done a lot in
the past. I'm an ICS user since around 1999 and I can tell you that
it's rock-solid.

I think you should study the TcpSrv demo, as I've learned a lot with it.

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE
Said in other word: How do I find the index to use with Client[] property 
?
We cannot answer that question for you because we don't know the criteria 
!

You can create a form to ask the user which IP the client has and then
iterate thru Client[] array and look for the correct IP.



Yes,
This is what I need and Iam trying to send command to the client by using 
it's IP
As I can see here (OnProcessData) that I am getting the IP -- 
Client.SendStr(AClient.PeerAddr + ':' + AClient.GetPeerPort + ' ' +

but,
I don't know how to do this, and that is what I have been looking in the 
demos to find today.


Something like this ? (Out of my head, not tested)

for ClientNo := 0 to WSocketServer1.ClientCount - 1 do begin
   if Client[ClientNo].PeerAddr = '192.168.1.123' then begin
   Client[ClientNo].SendStr('HelloWorld'#13#10);
   break;
   end;
end;

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Something like this ? (Out of my head, not tested)

for ClientNo := 0 to WSocketServer1.ClientCount - 1 do begin
   if Client[ClientNo].PeerAddr = '192.168.1.123' then begin
   Client[ClientNo].SendStr('HelloWorld'#13#10);
   break;
   end;
end;



Hi Francois,
Could you please check the following code of both server and client 
procedures and tell me what is missing in order to be able to get the client 
number into the DISPLAY with the all other info.This is code writen by you 
i think. I have add few things and there might be mistakes.



I am certain, I will be okay after that.

Thanks a lot in advance.

Here is procedures OnDataAvailable and ProcessData of the SERVER
-
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*}
procedure TSimpleSslServerForm.ClientDataAvailable(
   Sender : TObject;
   Error  : Word);
begin
   with Sender as TTcpSrvClient do begin
   { We use line mode. We will receive complete lines }
   RcvdLine := ReceiveStr;
   { Remove trailing CR/LF }
   while (Length(RcvdLine)  0) and
 IsCharInSysCharSet(RcvdLine[Length(RcvdLine)], [#13, #10]) do
   RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
   Display('Received from ' + GetPeerAddr + ': ''' + RcvdLine + );
   ProcessData(Sender as TTcpSrvClient);
   end;
end;

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*}
procedure TSimpleSslServerForm.ProcessData(Client: TTcpSrvClient);
var
   I   : Integer;
   P   : Pointer;
   AClient : TTcpSrvClient;
begin
   { We could replace all those CompareText with a table lookup }
   if CompareText(Client.RcvdLine, 'help') = 0 then
   Client.SendStr('Commands are:' + #13#10 +
  '  exit' + #13#10 +
  '  who' + #13#10 +
  '  time' + #13#10 +
  '  exception' + #13#10 +
  '  binary [size]' + #13#10)
   else if CompareText(Copy(Client.RcvdLine, 1, 6), 'binary') = 0 then
   begin
   I := StrToIntDef(Copy(Client.RcvdLine, 7, MaxInt), 0);
   if I = 0 then
   Client.SendStr('500 Error binary size not spezified'#13#10)
   else begin
   if I  MaxWord then
   begin
   Client.SendStr('500 Error binary size limited to ' +
  IntToStr(MaxWord) + ' bytes'#13#10);
   Exit;
   end
   else
   Client.SendStr('200 OK Binary ' + IntToStr(I) +
  ' bytes requested'#13#10);
   Inc(I, SizeOf(THdrRec));
   GetMem(P, I);
   try
   FillChar(P^, I, '1');
   PHdrRec(P)^.ID  := 0; // any value  32 marks = valid
binary data.
   PHdrRec(P)^.Size:= I - SizeOf(THdrRec);
   PAnsiChar(P)[I - 1] := 'E';
   Client.Send(P, I);
   finally
   FreeMem(P);
   end;
   end;
   end
   else if CompareText(Client.RcvdLine, 'exit') = 0 then
   { We can't call Client.Close here because we will immediately }
   { reenter DataAvailable event handler with same line because  }
   { a line is removed from buffer AFTER it has been processed.  }
   { Using CloseDelayed will delay Close until we are out of }
   { current event handler.  }
   Client.CloseDelayed
   else if CompareText(Client.RcvdLine, 'time') = 0 then
   { Send server date and time to client }
   Client.SendStr(DateTimeToStr(Now) + #13#10)
   else if CompareText(Client.RcvdLine, 'who') = 0 then begin
   { Send client list to client }
   Client.SendStr('There are ' +
IntToStr(SslWSocketServer1.ClientCount) +
  ' connected users:' + #13#10);
   for I := SslWSocketServer1.ClientCount - 1 downto 0 do begin
   AClient := TTcpSrvClient(SslWSocketServer1.Client[I]);
   Client.SendStr(AClient.PeerAddr + ':' + AClient.GetPeerPort + '
' +
  DateTimeToStr(AClient.ConnectTime) + #13#10);
   end;
   end
   else if CompareText(Client.RcvdLine, 'exception') = 0 then
   { This will trigger a background exception for client }
   PostMessage(Client.Handle, Client.FMsg_WM_TRIGGER_EXCEPTION, 0, 0)
   else
   if Client.State = wsConnected then
   Client.SendStr('Unknown command: ''' + Client.RcvdLine +  +
#13#10);
end;
-
And here is OnDataAvailable for the client.
-
procedure TfrmMain.SockDataAvailable(Sender: TObject; ErrCode: Word);
var
   Buf : array [0..255] of AnsiChar;
   Len : Integer;
begin
   Len := 

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Have a look at the event OnClientConnect, this is called whenever a
client connect, just grab the client info there and you should be good
to go.

Thank you :)
Now we are getting close.

Here is what I have,
and please see the line for the client number,
Now I at least now where should I define it, just need to find out how?
---
procedure TSimpleSslServerForm.SslWSocketServer1ClientConnect(
   Sender : TObject;
   Client : TWSocketClient;
   Error  : Word);
begin
   with Client as TTcpSrvClient do begin
   Display('Client connected.' +
   '[]' + ///Here I need to get the client number into the 
brackets

   ' Remote: ' + PeerAddr + '/' + PeerPort +
   ' Local: '  + GetXAddr + '/' + GetXPort);
   Display('There is now ' +
   IntToStr(TWSocketServer(Sender).ClientCount) +
   ' clients connected.');
   LineMode:= True;
   LineEdit:= True;
   LineLimit   := 80; { Do not accept long lines }
   OnDataAvailable := ClientDataAvailable;
   OnLineLimitExceeded := ClientLineLimitExceeded;
   OnBgException   := ClientBgException;
   OnSslVerifyPeer := ClientVerifyPeer;
   ConnectTime := Now;
   end;
end;
.

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Francois PIETTE

Could you please check the following code


I normally don't review large chunk of code within free support. I usually 
do that when I have a consulting contract.


Could you please check the following code of both server and client 
procedures and tell me what is missing in order to be able to get the 
client number into the DISPLAY with the all other info.This is code 
writen by you i think. I have add few things and there might be mistakes.


I don't know what the client number is. If it is the index in the client[] 
property, then you are on the wrong track. That index vary as clients 
connects and disconnects ! The index may be used only in temporary operation 
will the list won't change, for example within the handling of an event. 
using the index on the long term is a bad idea.


In my opinion, each of your client should be assigned an unique ID, either 
sent my the client himself, or generated by the server (Simple incrementing 
number). The ID is somewhat necessary because you may have several client 
from the same computer and hence have the same IP for several clients. You 
could also use IP:Port as an ID.


As Marc told you, if you need to display a list of client, real time, you 
have to use the WSocketServer OnClientConnect and OnClientDisconnect events 
to add/:remove items to/from the list you use for display. in both events 
you have access to the client instalnce and can thus access PeerAddr, 
PeerPort and any other data you may have (One of the demo save the time of 
connection just for demo purpose).


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Marc Charbonneau
 Here is what I have,
 and please see the line for the client number,
 Now I at least now where should I define it, just need to find out how?
 ---
 procedure TSimpleSslServerForm.SslWSocketServer1ClientConnect(
   Sender : TObject;
   Client : TWSocketClient;
   Error  : Word);
 begin
   with Client as TTcpSrvClient do begin
       Display('Client connected.' +
               '[]' + ///Here I need to get the client number into the
 brackets
               ' Remote: ' + PeerAddr + '/' + PeerPort +
               ' Local: '  + GetXAddr + '/' + GetXPort);
       Display('There is now ' +
               IntToStr(TWSocketServer(Sender).ClientCount) +
               ' clients connected.');
       LineMode            := True;
       LineEdit            := True;
       LineLimit           := 80; { Do not accept long lines }
       OnDataAvailable     := ClientDataAvailable;
       OnLineLimitExceeded := ClientLineLimitExceeded;
       OnBgException       := ClientBgException;
       OnSslVerifyPeer     := ClientVerifyPeer;
       ConnectTime         := Now;
   end;
 end;

Actually, TWSocketServer(Sender).ClientCount-1 will be your client
number, until one of the client disconnect.

Since it's a dynamic array, when a client disconnect, the client
number will change.

That`s why you need another way to identify your clients.

From memory, when my client connected, they would send the server
their unique ID and I would store that into a property of the client
socket. You have to derive your client socket and add properties to
it.

Something like :

  TTcpSrvClient = class(TWSocketClient)
  public
ConnectTime : TDateTime;
UniqueID : string;
  end;

then you assign that client socket in the server initialization (in
the TcpSrv demo,in WMAppStartup) :

WSocketServer1.ClientClass := TTcpSrvClient; { Use our component }

Then when I wanted to send a command to a particular client, I would
just iterate all connected client searching for the right ID.

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

Marc,
Why we are jumping to the another planet now?
We are soo close!!

Can you please see the code!
This is just getting complicated all the time.

Isn't this component having anything such as: CLIENTID?, CLIENTNO?, ID? 
which could be posted here in the same way as the IP address and the Port?


Come on guys,
This can't be this complicated!
too many opinions but none simple??


Here is what I have,
---
procedure TSimpleSslServerForm.SslWSocketServer1ClientConnect(
  Sender : TObject;
  Client : TWSocketClient;
  Error  : Word);
begin
  with Client as TTcpSrvClient do begin
  Display('Client connected.' +
  '[' + THEID or the CLIENTNUMBER or ANYTHING which helps to 
identify + ']' + ///Here I need to get this info into the

brackets
  ' Remote: ' + PeerAddr + '/' + PeerPort +
  ' Local: '  + GetXAddr + '/' + GetXPort);
  Display('There is now ' +
  IntToStr(TWSocketServer(Sender).ClientCount) +
  ' clients connected.');
  LineMode:= True;
  LineEdit:= True;
  LineLimit   := 80; { Do not accept long lines }
  OnDataAvailable := ClientDataAvailable;
  OnLineLimitExceeded := ClientLineLimitExceeded;
  OnBgException   := ClientBgException;
  OnSslVerifyPeer := ClientVerifyPeer;
  ConnectTime := Now;
  end;
end;


Actually, TWSocketServer(Sender).ClientCount-1 will be your client
number, until one of the client disconnect.

Since it's a dynamic array, when a client disconnect, the client
number will change.

That`s why you need another way to identify your clients.


From memory, when my client connected, they would send the server

their unique ID and I would store that into a property of the client
socket. You have to derive your client socket and add properties to
it.

Something like :

 TTcpSrvClient = class(TWSocketClient)
 public
   ConnectTime : TDateTime;
   UniqueID : string;
 end;

then you assign that client socket in the server initialization (in
the TcpSrv demo,in WMAppStartup) :

   WSocketServer1.ClientClass := TTcpSrvClient; { Use our component }

Then when I wanted to send a command to a particular client, I would
just iterate all connected client searching for the right ID.

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread Marc Charbonneau
 Marc,
 Why we are jumping to the another planet now?
 We are soo close!!

 Can you please see the code!
 This is just getting complicated all the time.

 Isn't this component having anything such as: CLIENTID?, CLIENTNO?, ID?
 which could be posted here in the same way as the IP address and the Port?

 Come on guys,
 This can't be this complicated!
 too many opinions but none simple??

Well, like Francois said, you can use PeerAddr + PeerPort combination
to get a unique identifier.

I don't think there is a simpler way. But like I said, it's been a
long time since I played with that.

Sorry if I can't be more helpful.

If you REALLY can't figure it out, let me know and I'll play with it
to try to find a solution for you.

hth
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-17 Thread daniel cc

If you REALLY can't figure it out, let me know and I'll play with it
to try to find a solution for you.




Thanks Marc,
Have been playing 2 days with this and still can't find out the way how  to 
do.


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Francois PIETTE

Hello daniel,

As I said before, please FIRST do the job WITHOUT SSL. You'll add SSL later. 
It is the same component with or without SSL. Simply the SSL code is 
compiled with the conditinal symbol use_ssl so that application which do 
not require SSL stay independent of OpenSSL and stay smaller.


In my last message, I pointed you to two samples. Please start from there.

Regards,
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: daniel cc dan...@signedsource.com

To: TWSocket twsocket@elists.org
Sent: Sunday, January 16, 2011 5:13 PM
Subject: [twsocket] SslWSocketServer  SslWSocket



Hi all,
I have spent 4 days trying to send and receive data from 
 “SslWSocketServer” to “SslWSocket”, with no success.


What am I trying to do?
I am trying to send and receive data from “SslWSocketServer” to 
“SslWSocket” (to a connected client/clients),

send and receive data from “SslWSocket” to “SslWSocketServer”.

The data is simple, which is the text of a “TEdit” component for now and 
later I would like to be able to do the same thing for files.


I have tryed everything available in the component demo library with no 
success because looks like every demo sample does the things in some ways 
but none does in the way (this is I believe is the simplest way) I need.
It is almost impossible for me to understand and digg up something from 
the demo samples because I am a beginner.


Please notice!
I need to do this with “SSL” components not with the regular components 
because I have no need of doing this with regular components.


I would be very pleased if someone could,
- Help me with a sample of this
- Guide me to a right demo/sample where I could perhaps digg up

Thanks in advance

-daniel


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread daniel cc

Hi Francois,
Thanks for the response.
I wish to continue with SSL if there is no difference.

This is the last message I have received from you regarding,

Please start by fully understanding OverbyteIcsSrvTcp and OverbyteIcsClient7
samples. Forget about SSL right now, you'll come back to it once you master
the basics.

Ask all questions you need to fully understand OverbyteIcsSrvTcp and
OverbyteIcsClient7 samples. The OnDataAvailable handler is procedure
TTcpDaemon.ClientDataAvailable and in procedure
TCli7Form.WSocket1DataAvailable.
-
Now,
The project OverbyteIcsSrvTcp has absolutely nothing in inside to help me. 
I can't find anything about sending or receiving in this project.


The project OverbyteIcsClient7  gives me nothing else but errors 
saying -- Socket not connected!



This is all what I can see in this project, which I already have tryed to 
use with no success.

--
procedure TCli7Form.WSocket1DataAvailable(
Sender  : TObject;
ErrCode : Word);
var
   Buf : array [0..255] of AnsiChar;
   Len : Integer;
begin
   Len := TCustomLineWSocket(Sender).Receive(@Buf, Sizeof(Buf) - 1);
   if Len = 0 then
   Exit;
   Buf[Len] := #0;
   if not WSocket1.LineMode then
   { Normal mode, data is just a buffer with all caracters }
   Display('DataAvailable (' + IntToStr(Len) +' bytes): ''' +
   String(StrPas(Buf)) + )
   else begin
   { Line mode, buffer contains exactly one line, terminated by the }
   { LineEnd string, unless our buffer is too small in which case   }
   { the line is truncated. We'll get the end of line on the next   }
   { call to Receive.   }
   Display('Line: ''' + RemoveEndOfLine(String(StrPas(Buf))) + );
   end;
end;






-Original Message- 
From: Francois PIETTE

Sent: Sunday, January 16, 2011 7:08 PM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer  SslWSocket

Hello daniel,

As I said before, please FIRST do the job WITHOUT SSL. You'll add SSL later.
It is the same component with or without SSL. Simply the SSL code is
compiled with the conditinal symbol use_ssl so that application which do
not require SSL stay independent of OpenSSL and stay smaller.

In my last message, I pointed you to two samples. Please start from there.

Regards,
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: daniel cc dan...@signedsource.com

To: TWSocket twsocket@elists.org
Sent: Sunday, January 16, 2011 5:13 PM
Subject: [twsocket] SslWSocketServer  SslWSocket



Hi all,
I have spent 4 days trying to send and receive data from 
 “SslWSocketServer” to “SslWSocket”, with no success.


What am I trying to do?
I am trying to send and receive data from “SslWSocketServer” to 
“SslWSocket” (to a connected client/clients),

send and receive data from “SslWSocket” to “SslWSocketServer”.

The data is simple, which is the text of a “TEdit” component for now and 
later I would like to be able to do the same thing for files.


I have tryed everything available in the component demo library with no 
success because looks like every demo sample does the things in some ways 
but none does in the way (this is I believe is the simplest way) I need.
It is almost impossible for me to understand and digg up something from 
the demo samples because I am a beginner.


Please notice!
I need to do this with “SSL” components not with the regular components 
because I have no need of doing this with regular components.


I would be very pleased if someone could,
- Help me with a sample of this
- Guide me to a right demo/sample where I could perhaps digg up

Thanks in advance

-daniel


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread RTT



Now,
The project OverbyteIcsSrvTcp has absolutely nothing in inside to 
help me. I can't find anything about sending or receiving in this 
project.


The OverbyteIcsSrvTcp uses the OverbyteIcsTcpCmd.pas, where you will 
find the code of the server.




The project OverbyteIcsClient7  gives me nothing else but errors 
saying -- Socket not connected!


Make sure you have the server running, before you hit the client connect 
button.
Make also sure the client port is set to the same server port. The 
server port is set to 2120, as you can see here in the code, file 
OverbyteIcsTcpCmd.pas


constructor TTcpDaemon.Create;
begin
inherited Create;
WSocketServer1:= TWSocketServer.Create(nil);
WSocketServer1.Banner := 'ICS Tcp Service Ready';
FPort := '2120';
FAddr := '0.0.0.0';
end;

So, make sure you set the client to port 2120 too.

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread daniel cc

The OverbyteIcsSrvTcp uses the OverbyteIcsTcpCmd.pas, where you will
find the code of the server.



Yes,
I already knew this.



Make sure you have the server running, before you hit the client connect
button.
Make also sure the client port is set to the same server port. The
server port is set to 2120,
So, make sure you set the client to port 2120 too.




Yes,
I knew this too.
And I still can't make it work,
It gives error when clicking the connect button and it gives error when 
clicking the send button.


however,
I will be able to fix the errors but,
this still doesn't help me much because,
I need to be able to send the commands from the server to the client as 
well.
I can find nothing about how to send anything from server to the selected 
client.


Thanks.

-daniel


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread RTT



It gives error when clicking the connect button


What's the connect error?



however,
I will be able to fix the errors but,
this still doesn't help me much because,
I need to be able to send the commands from the server to the client 
as well.
I can find nothing about how to send anything from server to the 
selected client.


My understanding, and I may be wrong here, is that:

- Servers listen and respond to clients requests.
- Clients request from, or send something to, servers.
- Clients must start the connection.

So probably you need a server/client in both nodes of the connection.
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Arno Garrels
daniel,

 I wish to continue with SSL if there is no difference.

SSL is an add-on, so skip that for now, you have to understand the
basics first . 

 Now,
 The project OverbyteIcsSrvTcp has absolutely nothing in inside to
 help me. I can't find anything about sending or receiving in this
 project. 

Huch? There's method WSocket1DataAvailable that receives data
and SendButtonClick that sends strings.

 The project OverbyteIcsClient7  gives me nothing else but errors
 saying -- Socket not connected!

TCP/IP requires a connection before data can be sent or received.
A client has to connect to the server first.

 This is all what I can see in this project, which I already have
 tryed to use with no success.

 procedure TCli7Form.WSocket1DataAvailable(
 Sender  : TObject;
 ErrCode : Word);
[snip]


This method triggers whenever data sent by the server is received.

But wait, I just found and fixed a bug in OverbyteIcsCli7 that was introduced
during the Unicode conversion. Exchange function RemoveEndOfLine by :

function RemoveEndOfLine(const Line : String) : String;
begin
if (Length(Line) = Length(EndOfLine)) and
   (StrLComp(PChar(@Line[1 + Length(Line) - Length(EndOfLine)]),
 PChar(EndOfLine),
 Length(EndOfLine)) = 0) then
Result := Copy(Line, 1, Length(Line) - Length(EndOfLine))
else
Result := Line;
end;

-- 
Arno Garrels

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread daniel cc

Huch? There's method WSocket1DataAvailable that receives data
and SendButtonClick that sends strings.


There is no such button SendButtonClick in this project -- 
OverbyteIcsSrvTcp.bdsproj.

Are we talking about the same project or is it something which I don't have?


TCP/IP requires a connection before data can be sent or received.
A client has to connect to the server first.



Absolutely.




This method triggers whenever data sent by the server is received.

But wait, I just found and fixed a bug in OverbyteIcsCli7 that was 
introduced

during the Unicode conversion. Exchange function RemoveEndOfLine by :

function RemoveEndOfLine(const Line : String) : String;
begin
   if (Length(Line) = Length(EndOfLine)) and
  (StrLComp(PChar(@Line[1 + Length(Line) - Length(EndOfLine)]),
PChar(EndOfLine),
Length(EndOfLine)) = 0) then
   Result := Copy(Line, 1, Length(Line) - Length(EndOfLine))
   else
   Result := Line;
end;




This has fixed the error :)
I can now send from client to the server.

But,
I still can't send anything from server to the client. 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Francois PIETTE

I wish to continue with SSL if there is no difference.


There is a difference: you introduce something in extra which has a lot of 
reason not to work. First thing first, start without SSL.


The project OverbyteIcsSrvTcp has absolutely nothing in inside to help 
me.


Sure it has ! It accept connections from client and execute commands send by 
clients.



I can't find anything about sending or receiving in this project.


Sure you can find for receiving and sending: the sample is all about 
receiving commands from clients, execute it and send result back.


The project OverbyteIcsClient7  gives me nothing else but errors 
saying -- Socket not connected!


If you try to send before being connected, you get this error.
This is a client and it only works with a server (for example the other 
sample). You must connect the client to the server firts. Then you may send 
something.


This is all what I can see in this project, which I already have tryed to 
use with no success.


You won't go any further if you don't understand both samples. They are the 
basic. Basic but realistic. Someone could do simpler but this won't be good 
programming in real world.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Francois PIETTE
I need to be able to send the commands from the server to the client as 
well.


Given a server has a lot of client (potentially), how do you select the 
client you want to communicate with ?
Usually a server reply to a command sent by a client, but once the client is 
connected, the server can send anything to the client, even without any 
prior request by the client.


I can find nothing about how to send anything from server to the selected 
client.


Assuming N is the index of the selected client, you send something using 
this line of code:

   WSocketServer.Client[N].Send(MyBufAddr, MyBufLnegth);

When sending something back to a client having sent a command, you use the 
sender argument of the dataavailable event. This sender represent the 
client:

  TWSocket(Sender).Send(MyBufAddr, MyBufLnegth);

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread daniel cc


Assuming N is the index of the selected client, you send something using 
this line of code:

   WSocketServer.Client[N].Send(MyBufAddr, MyBufLnegth);

When sending something back to a client having sent a command, you use the 
sender argument of the dataavailable event. This sender represent the 
client:

  TWSocket(Sender).Send(MyBufAddr, MyBufLnegth);



I still can't find anything regarding this in existed demos/samples.

Thanks

-daniel

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread daniel cc

Assuming N is the index of the selected client, you send something using
this line of code:
   WSocketServer.Client[N].Send(MyBufAddr, MyBufLnegth);

When sending something back to a client having sent a command, you use the
sender argument of the dataavailable event. This sender represent the
client:
  TWSocket(Sender).Send(MyBufAddr, MyBufLnegth);

And also,
Do I need anthing else for the TWSocket like OnSendData, OnConnect, 
OnDisconnect?
I am sorry to say but this -- WSocketServer.Client[N].Send(MyBufAddr, 
MyBufLnegth);


I have already tryed this in dozens of ways and it doesn't work -- 
TWSocket(Sender).Send(MyBufAddr, MyBufLnegth); or I simply can't make it 
work.





--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Francois PIETTE
When sending something back to a client having sent a command, you use the 
sender argument of the dataavailable event. This sender represent the 
client:

  TWSocket(Sender).Send(MyBufAddr, MyBufLnegth);



I still can't find anything regarding this in existed demos/samples.


In the server sample, this is handled in TTcpDaemon.ProcessData which is 
called from TTcpDaemon.ClientDataAvailable which passes sender as 
TTcpSrvClient to ProcessData as its client argument. TTcpSrvClient inhérit 
from TWSocket.


Please run OverbyteIcsSrvTcp under the debugger. Place a breakpoint on the 
first line of TTcpDaemon.ClientDataAvailable. Then use OverbyteIcsClient7 
sample to connect to the server and send something. Your breakpoint will be 
reached. From there, single step to understand what happend (Do not 
singlestep in TWSocket or TWSocketServer for now, it would be to complex at 
this stage).


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] SslWSocketServer SslWSocket

2011-01-16 Thread Francois PIETTE
and it doesn't work 


Please be more specific. What error/exception do you have ?

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be