Thread View: borland.public.cppbuilder.internet.socket
7 messages
7 total messages
Started by Vladimir Stefanovic
Fri, 30 Sep 2005 06:14
TIdTCPClient/TIdTCPServer communication
Author: Vladimir Stefanovic
Date: Fri, 30 Sep 2005 06:14
Date: Fri, 30 Sep 2005 06:14
43 lines
2218 bytes
2218 bytes
Hi, I want to use Indy to do the same thing that I knew with TClientSocket/TServerSocket: 1) TClientSocket (ctNonBlocking) sends buffer of data (possibly lots of data) to TServerSocket( stBlocking/ OnGetThread ) 2) TServerSocket receives data in a thread, in nagotiated protocol, for example: "buffer_length buffer" 3) TServerSocket sends back the confirmation to client that the operation was successful or not. * Which Indy components are the most suitable for that (I suppose TIdTCPClient/TIdTCPServer)? * Am I supposed to send data in peaces (buffer portins), then look how much data was actually sent, and continue from that place like I did with TClientSocket/TServerSocket? The same was with server. * I looked at methods of TIdTCPClient::TIdConnection and I saw many methods for sending data: Write, WriteBuffer, WriteCardinal, WriteFile, WriteHeader, WriteInteger, WriteLn, WriteSmallInt, WriteStream, WriteStrings. I remember that even in TClientSocket I had SendText() which was not reliabe because noone can guarantee that *all* the buffer will be sent at the same time. Is the same here? * Can someone show some working code? -- Best regards, Vladimir Stefanovic
Re: TIdTCPClient/TIdTCPServer communication
Author: Remy Lebeau (TeamB)
Date: Fri, 30 Sep 2005 06:23
Date: Fri, 30 Sep 2005 06:23
56 lines
2856 bytes
2856 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message news:433cd755@newsgroups.borland.com... > I want to use Indy to do the same thing that I > knew with TClientSocket/TServerSocket: Indy can do everything TClient/ServerSocket does, and more. > 1) TClientSocket (ctNonBlocking) sends buffer of data > (possibly lots of data) to TServerSocket( stBlocking/ > OnGetThread ) > > 2) TServerSocket receives data in a thread, in nagotiated > protocol, for example: "buffer_length buffer" > > 3) TServerSocket sends back the confirmation to client > that the operation was successful or not. Ok so far. > Which Indy components are the most suitable for that > (I suppose TIdTCPClient/TIdTCPServer)? Yes. > Am I supposed to send data in peaces (buffer portins), then > look how much data was actually sent, and continue from > that place like I did with TClientSocket/TServerSocket? No. When you write data with Indy, you can write the entire data at one time, and Indy will internally send it in portions as needed. As far as your own code is concerned, whichever writing method you call will not return control to your code until the specified data is passed to the socket in full. > The same was with server. Likewise, when you read data with Indy, you tell Indy how much to read, and it waits until all of the data is received in full before then returning control to your code. > I remember that even in TClientSocket I had SendText() > which was not reliabe because noone can guarantee that > *all* the buffer will be sent at the same time. That is true, although SendText() does return how many bytes were sent, so that you can call SendText() with the remaining string data if needed. > Is the same here? No. When you call Indy's Write(String) method, for instance, Write() does not return until the entire string is passed to the socket in full. Gambit
Re: TIdTCPClient/TIdTCPServer communication
Author: Remy Lebeau (TeamB)
Date: Fri, 30 Sep 2005 06:24
Date: Fri, 30 Sep 2005 06:24
12 lines
1291 bytes
1291 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message news:433cd755@newsgroups.borland.com... > Can someone show some working code? A better thing to do would be for you to show your original TClient/ServerSocket code so that someone can then show you how to translate it into Indy code. Gambit
Re: TIdTCPClient/TIdTCPServer communication
Author: Vladimir Stefanovic
Date: Fri, 30 Sep 2005 07:35
Date: Fri, 30 Sep 2005 07:35
5 lines
984 bytes
984 bytes
Thank you. -- Best regards, Vladimir Stefanovic
Re: TIdTCPClient/TIdTCPServer communication
Author: Vladimir Stefanovic
Date: Fri, 30 Sep 2005 07:48
Date: Fri, 30 Sep 2005 07:48
20 lines
1537 bytes
1537 bytes
> A better thing to do would be for you to show your original > TClient/ServerSocket code so that someone can then show > you how to translate it into Indy code. Ok, I'll post my TClientSocket/TServerSocket code tomorrow, because now I'm in a great hurry (must go to Belgrade airport to wait for my uncle from Canada). P.S. I subscribed yesterday to: news.atozedsoftware.com / *indy*, and I saw that you are prety frequent there. Have you took part in creation of Indy? -- Best regards, Vladimir Stefanovic
Re: TIdTCPClient/TIdTCPServer communication
Author: Remy Lebeau (TeamB)
Date: Fri, 30 Sep 2005 17:11
Date: Fri, 30 Sep 2005 17:11
12 lines
1342 bytes
1342 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message news:433ced70@newsgroups.borland.com... > I subscribed yesterday to: news.atozedsoftware.com / *indy*, > and I saw that you are prety frequent there. Have you took > part in creation of Indy? I am a member of Indy's development and administration teams. Gambit
Re: TIdTCPClient/TIdTCPServer communication
Author: Vladimir Stefanovic
Date: Tue, 04 Oct 2005 17:36
Date: Tue, 04 Oct 2005 17:36
45 lines
2591 bytes
2591 bytes
>> Can someone show some working code?
>
> A better thing to do would be for you to show your
> original TClient/ServerSocket code so that someone
> can then show you how to translate it into Indy code.
Hi,
This is one of the imaginary scenarios that I want to
port to Indy.
1) CLIENT: Sends request (buffer of data) to SERVER
2) SERVER: Receives request (buffer of data) from CLIENT
3) SERVER: Processes the received buffer of data and
prepares a response
4) SERVER: Sends response to CLIENT of the processing success
5) CLIENT: Receives response from SERVER and shows the message
For example, this should check if the file exists on the server
machine (by the logic of TClintSocket/TServerSocket):
1) CLIENT SENDS BUFFER: buffer_size ASK C:\Autoexec.bat
2) SERVER RECEIVES BUFFER: ASK C:\autoexec.bat
3) SERVER RESOLVES 'ASK' COMMAND AND SERACHES FOR FILE:
FileExists("C:\\autoexec.bat)" AND PREPARES RESPONSE
4) SERVER SENDS BACK BUFFER: buffer_size MSG File exists!
5) CLIENT RECEIVES BUFFER: MSG File exists! and shows the
message "File 'autoexec.bat' exists on server machine".
This is how whould I do it with TServerSocket/TClientSocket
(CLIENT: ctNonBlocking, SERVER: stThreadBlocking):
[I attached Both CLIENT&SERVER CODE & EXE's in the
Attachments group]
I wanted to place the code directly here but unfortunately,
the working code appeared to be too big for the message body.
If you still think that I should place it here, I'll do that.
--
Best regards,
Vladimir Stefanovic
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads