Re: [twsocket] SslWSocketServer Send and receive
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" To: "ICS support mailing" 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
Re: [twsocket] SslWSocketServer Send and receive
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. Could you please inform the name of these samples? Thanks in advance -daniel -- 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" To: "ICS support mailing" 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 -- 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 Send and receive
> To receive data, each side install an OnDataAvailable event handler > and from there call Receive to get hand on data. > Could you please inform the name of these samples? Do you know how to use search? OverbyteIcsConSrv1C.pas OverbyteIcsDynCli1.pas OverbyteIcsMtSrv2.pas OverbyteIcsRecv1.pas OverbyteIcsTcpCmd.pas OverbyteIcsTcpSrv1.pas OverbyteIcsThrdSrv1.pas OverbyteIcsThrdSrvV2_1.pas OverbyteIcsThrdSrvV3_1.pas OverbyteIcsTnDemo1.pas OverbyteIcsTWSChat1.pas OverbyteIcsHttpsServer1.pas OverbyteIcsSimpleSslServer1.pas OverbyteIcsSslSniSrv1.pas Clearly you did not read my earlier message, or you would not be asking many of these questions, but would have your project working already. 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 Send and receive
Clearly you did not read my earlier message, or you would not be asking many of these questions, but would have your project working already. Angus Thanks Angus, I did read your early message. I unfortunately can't get anything out of it because I am not that good to understand and do right away what you are telling. I still need some names of the examples where the info is not the entire library which I have no idea about what to search. I will be very pleased if you guys could stop treating me as a guru which I am not. I am just a beginner and the things you explain me to do aren't that simple for me to do if there aren't any 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 Send and receive
To receive data, each side install an OnDataAvailable event handler and from there call Receive to get hand on data. Could you please inform the name of these samples? 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". 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 -- 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 Send and receive
> I unfortunately can't get anything out of it because I am not that > good to understand and do right away what you are telling. You should first run two or more instances of the EXE demo in Magenta Systems IP Log Streaming Component I referred before, one as client, one as server, they will show sending packets to each other without even opening Delphi. Then look at the source code for the EXE demo and you will see one method to send a packet (a line of text), one event to receive a packet (that line). You copy code from that demo and the core of your application is running in 30 minutes without needing to understand any more about TWSocket, or be concerned about onDataAvailable or such low level events. Note the logger component does not use SSL, but SSL is something you can add to your project much later, when you have a hundred more important things working properly. And once you have read the SSL book and fully understand certificates, which is not trivial or for beginners. > I am just a beginner and the things you explain me to do aren't > that simple for me to do if there aren't any samples. We have pointed out several examples already. You also need to think about the hardware requirements to develop and test your project, you will needs multiple PCs or at least multiple VMs on one PC to test anything properly. The server PCs will need domain names, with SSL certificates generated for them. I had eight PCs when I was developing an identical project. Don't expect to test this on end user PCs. 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 Send and receive
Thanks Angus, Now I understand you perfectly :) Thank you very much for the help and for being pation. I will continue from here and see how forward I can go. Best regards -Original Message- From: Angus Robertson - Magenta Systems Ltd Sent: Saturday, January 15, 2011 4:41 PM To: twsocket@elists.org Subject: Re: [twsocket] SslWSocketServer Send and receive I unfortunately can't get anything out of it because I am not that good to understand and do right away what you are telling. You should first run two or more instances of the EXE demo in Magenta Systems IP Log Streaming Component I referred before, one as client, one as server, they will show sending packets to each other without even opening Delphi. Then look at the source code for the EXE demo and you will see one method to send a packet (a line of text), one event to receive a packet (that line). You copy code from that demo and the core of your application is running in 30 minutes without needing to understand any more about TWSocket, or be concerned about onDataAvailable or such low level events. Note the logger component does not use SSL, but SSL is something you can add to your project much later, when you have a hundred more important things working properly. And once you have read the SSL book and fully understand certificates, which is not trivial or for beginners. I am just a beginner and the things you explain me to do aren't that simple for me to do if there aren't any samples. We have pointed out several examples already. You also need to think about the hardware requirements to develop and test your project, you will needs multiple PCs or at least multiple VMs on one PC to test anything properly. The server PCs will need domain names, with SSL certificates generated for them. I had eight PCs when I was developing an identical project. Don't expect to test this on end user PCs. 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 -- 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
[twsocket] SocketSpy
Hi All, I have done a cbuilder translation of Mr. Mestdagh's SpocketSpy program. But, I have a problem. When I run the program and try to connect with a server, I get this immediate error: "An unknown response was received in response to a request for information from the news server 'SocketSpyC++ Local TCP Proxy'" Under the details button of the error dialog, I get: SocketSpyC++ Local TCP Proxy Configuration: Account: SocketSpyC++ Local TCP Proxy Server: 127.0.0.1 Protocol: NNTP Port: 119 Secure(SSL): 0 Code: 800ccca0 I don't have any idea what the problem is. First, while trying to debug, I put a popup messagebox at the end of the WSocketServerClientConnect procedure to take a look at a variable. What I discovered was that messagebox being open allowed the program to actually connect and go further before error. After that, I replaced the messagebox with an Application->ProcessMessages() loop as a test. I was amazed that after that, the program ran completely and reliably--everytime. It works just great, but I haven't tried more than 1 connection because of the ProcessMessages loop. Though the loop has been helpful, I doubt it is the appropriate fix for this. I'm wondering if this problem is somehow related to changes made to cbuilder in the 2007 edition I'm using. I have already discovered and fixed 2 other problems related to the 2007 upgrade. I'm using Vista64. My source code is included below. I hope you'll forgive me if I have included too much code. My program is 257 lines. Please have a look. Regards, Richard Christman https://www.quicksilvermail.net socketwins.h: // --- #ifndef socketwinsH #define socketwinsH // --- #include #include #include #include #include "OverbyteIcsWndControl.hpp" #include "OverbyteIcsWSocket.hpp" #include "OverbyteIcsWSocketS.hpp" #include // --- class TSocketWin : public TForm { __published:// IDE-managed Components TRichEdit *TCPLog; TStatusBar *StatusBar; TEdit *RemoteAddr; TLabel *Label3; TEdit *RemotePort; TLabel *Label2; TEdit *LocalPort; TLabel *Label1; TButton *ListenBtn; TWSocketServer *WSocketServer; void __fastcall WSocketServerClientConnect(TObject *Sender, TWSocketClient *Client, WORD Error); void __fastcall WSocketServerClientDisconnect(TObject *Sender, TWSocketClient *Client, WORD Error); void __fastcall WSocketServerSessionClosed(TObject *Sender, WORD Error); void __fastcall ListenBtnClick(TObject *Sender); private:// User declarations void __fastcall BgException(TObject *Sender, Exception *E, bool &CanClose); void __fastcall ClientDataAvailable(TObject *Sender, WORD Error); void __fastcall RemoteSessionConnected(TObject *Sender, WORD Error); void __fastcall RemoteDataAvailable(TObject *Sender, WORD Error); void __fastcall RemoteSessionClosed(TObject *Sender, WORD Error); void __fastcall RemoteDnsLookupDone(TObject *Sender, WORD Error); public: // User declarations bool cancel; TStrings *log; __fastcall TSocketWin(TComponent* Owner); __fastcall virtual ~TSocketWin(); void __fastcall Log(AnsiString Msg); }; class TClient : public TWSocketClient { public: AnsiString rcvd; TWSocket *remote; __fastcall TClient(TComponent *Owner); __fastcall virtual ~TClient(); }; // --- extern PACKAGE TSocketWin *SocketWin; // --- #endif socketwins.cpp: // --- #include #pragma hdrstop #include "socketwins.h" // --- #pragma package(smart_init) #pragma link "OverbyteIcsWndControl" #pragma link "OverbyteIcsWSocket" #pragma link "OverbyteIcsWSocketS" #pragma resource "*.dfm" TSocketWin *SocketWin; const AnsiString lineend = "\r\n"; const bool linemode = true; // --- __fastcall TSocketWin::TSocketWin(TComponent* Owner) : TForm(Owner) { log = TCPLog->Lines; } // --- __fastcall TSocketWin::~TSocketWin() { } // --- void __fastcall TSocketWin::ListenBtnClick(TObject *Sender) { if (ListenBtn->Tag == 0) { NNTPLog->Clear(); WSocketServer->Banner = "Welcome to OverByte ICS TcpSrv"; WSocketServer