How do I send text comand from server to the client after it has established a connection to the server?

As I said, the server instanciate a new TWSocket to handle a client connexion. Actually the type of instanciated socket is given by the property ClientClass so that you can use your own to add anything needed for you application. All client socket instances are available in Client[] property. So to send something from server to client, you do something like WSocketServer1.Client[i].Send(blbalblabla); with "i" being the index of the client.

From the client, you have a single TWSocket. You do
wsocket1.Send(blablabla);

To receive data, each side install an OnDataAvailable event handler and from there call Receive to get hand on data.

All this is perfectly shown in many of the samples.

--
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: Saturday, January 15, 2011 12:23 AM
Subject: Re: [twsocket] SslWSocketServer Send and receive


Thanks Francois,
Sorry for not making myself clear :(
I already know these.

How do I send text comand from server to the client after it has established a connection to the server?
how do I do the same thing from client to the server?
for example: Server sends "Hello client" to the client and client answers "Hello server" to the server.
a little example perhaps?

And how do I do the same thing with the upload and download?
like server sends some file/files to the client and client sends some file/files to the server.
a little example?

Thanks in advance

-daniel

-----Original Message----- From: Francois PIETTE
Sent: Friday, January 14, 2011 11:23 PM
To: ICS support mailing
Subject: Re: [twsocket] SslWSocketServer Send and receive

1) I need to send from SslWSocketServer to SslWSocket,

A socket server cannot send any data to a client. The client has first to
establish the communication with the server. At server side, a new socket is
instanciated by SslWSocketServer to handle the communication with that
client. Then once the connection is open, it is working in both directions.
A server has to wait until the client connect. That's exactly what make a
server a server: passively waiting for client connection.

- Files (upload and download)
- Commands. Commands are just text lines like: change IP Address, change display resolution, reboot the machine ETC.

As far as the socket is concerned, files or commands is exactly the same
thing. A socket with an established connection is a bidirectional
transparent data stream. What you send at one end is received at the other
end. To send a file, you read the file block by block and you send each
block. You'd probably add some metadata in front of the file data so that
the receiver know at least the file size and maybe filename, timestamp and
so on. Basically that is what HTTP protocol is doing. You can reuse HTTP or
design your own protocol.

Commands being simple text lines, the socket has a line mode which will
facilitate your programming. When line mode is active, the socket will
assemble incomming data into lines and trigger OnDataAvailable for each
complete line no matter how it is spread into packets of various sizes.

2) I need to send from SslWSocket to SslWSocketServer,
- Files (upload and download)
- Commands. Commmands are just text lines like: CPU temp is: 60%, HDD space left: 10% ETC.

See above.

--
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
--
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

Reply via email to