My Asynchronous Socket blocks. Help!

Bines

New member
Joined
Aug 29, 2007
Messages
3
Programming Experience
Beginner
I am trying to write a small console application to connect to a particular telnet server via my internet connection. This remote server first asks for my username followed by my password. Then it sends occasional messages and accepts commands.

I am using Visual Basic 2005 Express and my code is based on the Asynchronous Client Socket Example from MSDN2 library.

I can connect OK to the server but can’t display the first message ( Login : ). The call to Receive(Client) returns OK but ReceiveDone.WaitOne() never returns and therefore I cannot display the login request or send my user name. Stepping through the code shows that 7 bytes have been received ( Login : ) as expected.

I can receive and send as expected when I write the code using a synchronous connection but I can’t have it blocking while waiting to send commands so I need to use asynchronous.

I suspect some sort of timing problem. I tried introducing small (1sec) time delays in the code but to no avail. If only Microsoft would release the source code for their telnet client in Windows XP I could see how it is done! Any ideas or pointers would be much appreciated.
 
Back
Top