Article View: borland.public.cppbuilder.internet.socket
Article #4534Re: Blocking Client
From: mike
Date: Thu, 20 Jan 2005 21:03
Date: Thu, 20 Jan 2005 21:03
63 lines
3147 bytes
3147 bytes
Remy, Thanks very much for replying, I appreciate your information. > A thread is not strictly required. Typically, a thread is only used when > you want to process data asynchronously, usually because you do not know > when data will be arriving. But if you are sending data, then reading a > response, for instance, then you don't need to use a thread, unless such > operations will block other code from working properly. > Ok I understand what you have indicated, but now I am confused as to how I would implement the reading of the data. Would I simply use a timer in which my WinSocketStream Wait ForData() is located. If I understand correctly the WaitForData() would stall all other operations until such time as data actually was received or it timed out. The application itself is required to send and receive data based upon the user making choices through button clicks and so forth. In this type of situation would I be better to use a thread as I don't know when or whaic type of data will be received from the server. Thanks Mike "Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:41f015df$1@newsgroups.borland.com... > > "mike" <mfbrowne@earthlink.net> wrote in message > news:41f00ec6$1@newsgroups.borland.com... > > > 1- Is there an example around that I could study to see how this is done. > > Go to http://www.deja.com and do a search. Same code has been posted many > times before. > > > - Set the Client Socket to Blocking. > > Yes. > > > - Once I have established a connect to the server, create my > > own thread that will do my reading of any data being received. > > A thread is not strictly required. Typically, a thread is only used when > you want to process data asynchronously, usually because you do not know > when data will be arriving. But if you are sending data, then reading a > response, for instance, then you don't need to use a thread, unless such > operations will block other code from working properly. > > > I do this using the WinSocketStream and the method > > WaitForData() - from this thread then process the message. > > Yes. > > > 3- For writing to the socket, do I need to have a separate thread. > > No. > > > Gambit > >
Technical Details
Message-ID:
<41f01cbc@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41f00ec6$1@newsgroups.borland.com> <41f015df$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,8975bc0a9ed70a81 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "mike" <mfbrowne@earthlink.net> Newsgroups: borland.public.cppbuilder.internet.socket References: <41f00ec6$1@newsgroups.borland.com> <41f015df$1@newsgroups.borland.com> Subject: Re: Blocking Client Date: Thu, 20 Jan 2005 16:03:27 -0500 Lines: 65 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 68.204.189.169 Message-ID: <41f01cbc@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1106255036 68.204.189.169 (20 Jan 2005 13:03:56 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail