Article View: borland.public.cppbuilder.internet.socket
Article #5501Re: {ctNonBlocking, ctBlocking} and {stNonBlocking, stThreadBlocking}
From: Remy Lebeau (TeamB)
Date: Fri, 13 Aug 2004 20:11
Date: Fri, 13 Aug 2004 20:11
90 lines
4512 bytes
4512 bytes
"Vladimir Stefanovic" <spam@not.needed> wrote in message news:411d1c29@newsgroups.borland.com... > 1) Is TMemoryStream appropriate container for the date > that has to be sent on client side and received on the > server side? If not, what is the adequate one? That depends on what you are actually trying to do. TMemoryStream is certainly not a requirement, but it can be helpful at times. That is a general code design issue, though. > 2) If I want to send 100 KB of data from a client to server, > and that't the only connection (only one client to connect to > the server) what should I use for a ClientType and what for > a ServerType. Again, that depends on your actual needs and program design. > a) What technique of sending should I use for this? You need to provide more details about what exactly you are trying to accomplish in the first place. > c) When some error occur while process of sending data, > is some kind of immediate retry of the whole process of any sense? That depends on the particular error. > d) How can I know that the data has been sent > successfuly in this case? You usually don't. If you call a sending function and it doesn't produce an error, then you can rest assured that the socket stack accepted the data into its internal buffers for transmission at a later time. Whether the buffered data actually reaches the other side of the connection is another matter, and one that you won't know unless there is an acknowledgement packet implemented in your communications, so that the receiver can tell the sender if/when data has arrived. > 3) When sending up to 100 bytes of ASCII string from only > one client to server, should I use SendText() insted of SendBuf()? It doesn't matter much since SendText() simply calls SendBuf(). What you do have to worry about in either case, however, is whether the full 100 bytes are accepted in one pass, or if you have to call SendText/Buf() multiple times when the data can't be sent in one piece. Both SendText() and SendBuf() return the number of bytes actually accepted for transmission. If less than 100, then you have to re-call SendText/Buf() passing in the remaining unsent data. > a) Why SendBuf() is usualy recomended one? There is less indirection involved, and also because SendBuf() is the primary function that actually passes the data to the socket stack. > b) Should I use the same ClientType and ServerType like in > point 2 ? It doesn't matter whether the client and server use the same threading model or not. That is completely independant on both ends of the connection. Clients have no concept of (and doesn't care about) whether the server is blocking or non-blocking, and vice versa. > 4) If I have two (or more) clients that in some moment (mabe the > same) wants to send the data (max 20 KB) to the client Do you mean to the server? > what ClientType and ServerType should I then use? It still doesn't matter much. The server will still recieve the data from both clients. That is why the server's event have a Socket parameter, so that your code can know which client the incoming data is coming from when received. > a) What technique of sending should I use? (I think > maybe of TWinSocketStream). TWinSocketStream only applies to blocking connections. Whether you use blocking or non-blocking is, again, depending on your actual needs and design. > b) How can I know that the data has been sent > successfuly in this case? See further above. Gambit
Technical Details
Message-ID:
<411d203b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<411d1c29@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,4c45334fb8a0a6bb
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <411d1c29@newsgroups.borland.com>
Subject: Re: {ctNonBlocking, ctBlocking} and {stNonBlocking, stThreadBlocking}
Date: Fri, 13 Aug 2004 13:11:24 -0700
Lines: 92
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <411d203b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1092427835 68.69.17.41 (13 Aug 2004 13:10:35 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail