Article View: borland.public.cppbuilder.internet.socket
Article #5323Re: How can I know that server is shutdowned?
From: Mark Jacobs
Date: Thu, 23 Sep 2004 16:47
Date: Thu, 23 Sep 2004 16:47
42 lines
2961 bytes
2961 bytes
My advice to you is not to use ctBlocking mode, whenever you can avoid doing so. I use non-blocking, and this works well. Some words I sent out recently about "Post"ing with non-blocking sockets :- Question : The OnSuccess or OnFailure callbacks are called BUT always before Post() returns. So I'm puzzled ? What is then the point of having these callbacks ? This may be because the actual sending of the raw http data is handled by Windows Sockets. The Post message is sent to Winsock and this gives a yeah or nay as to whether the pipe is able to handle the request (success or failure is then triggered) even though the data has not been sent yet. The same happens with non-blocking sockets (TServerSocket), in that a send request will return immediately, having queued up the data. TClientSocket uses an OnRead event to receive data in non-blocking mode. When this is triggered, the system has already received x bytes, and Winsock is triggering the event, either because its receive buffer is full, or because the entire datagram has been received. The function ReceiveLength tells you how many bytes Winsock has got for your app. The function ReceiveBuf returns the actual number of bytes transferred from Winsocks to your app (nearly always the same as ReceiveLength). To get the data, I use a construct like this in the OnRead event :- int ii=Socket->ReceiveBuf(rcvbfr,Socket->ReceiveLength()); This is how asynchronous comms has to work, in the uncertain world of connectivity. -- Mark Jacobs DK Computing http://www.dkcomputing.co.uk markj atty critical dotty co dotty uk "Vladimir Stefanovic" <spam@not.needed> wrote in message news:4152f591@newsgroups.borland.com... | Maybe it is in some connection with blocking modes at | client (which is ctBlocking at me). Unfortunately I'm not | currently at PC with BCB to test again.
Technical Details
Message-ID:
<4152fe29@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4152dced@newsgroups.borland.com> <4152f3b7@newsgroups.borland.com> <4152f591@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3dc3c1cc97f7872b X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Mark Jacobs" <markj atty critical dotty co dotty uk> From: "Mark Jacobs" <markj atty critical dotty co dotty uk> Newsgroups: borland.public.cppbuilder.internet.socket References: <4152dced@newsgroups.borland.com> <4152f3b7@newsgroups.borland.com> <4152f591@newsgroups.borland.com> Subject: Re: How can I know that server is shutdowned? Date: Thu, 23 Sep 2004 17:47:43 +0100 Lines: 44 Organization: DK Computing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 81.144.157.8 Message-ID: <4152fe29@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095958057 81.144.157.8 (23 Sep 2004 09:47:37 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail