07-05-2007 04:23 AM
07-05-2007 07:25 AM
The comparison is not done with the input line, but with an empty string. The input line control is only changed when you leave it or click enter, so the inside loop waits until you finished typing (the string is not empty) and only then it sends your string.
Actually, there are many things wrong with this example. For example, there is a race condition where the input string control is set to an empty string, but the loop could check before the control is actually cleared. It would have been cleaner to check for an empty string (and in newer versions, to just use an event structure, although that example is older) and so on.
For a better example, have a look at the multiple connections example. Also, you should have a look here.
It's important to handle connections over time. For example, keep a running counter of timeout errors (56). When you receive data, reset the counter. If the counter exceeded a limit, close the connection and reopen it.