The ConnectTo operation (as are all DataSocket operations) is asynchronous. In order for it to complete, you must process Windows messages after calling it and before calling another operation. Is it possible that you are trying to write data before the connection operation is complete?
One easy way to test this would be to put the ConnectTo and the Write in separate control callbacks, cause ConnectTo to be called, wait a while, then cause the Write to be called. Alternatively, you could do something like the following:
dsWrite.ConnectTo txtUrl.Text, cwdsWrite
While Not ((dsWrite.Status = cwdsConnectionActive) Or (dsWrite.Status = cwdsConnectionIdle))
DoEvents
Wend
If this is the problem, then you'll probably want to go with the
second option. In a production system, you should include a timeout in the While loop so that if the connection actually cannot be made, you are not stuck in an infinite loop.