In a socket class I have a method which essentially does this:
[ul]
[li]Declares a new socket[/li]
[li]Does a BeginConnect to connect to server (waits for connection)[/li]
[li]Sends data to the server (waits for send to complete)[/li]
[li]Receives a response from the server (waits for response to complete)[/li]
[li]Shuts down the socket and closes it[/li]
[/ul]
This works the first time I call the method. However, subsequent calls do not work. I get an error when data is sent: "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"
Sometimes the send will go through but I'll get the above error on the recieve part.
Now the strange thing is that if I step thru the code using F8, it works every time. When I run the code normally it will give me the error.
I don't know why the socket is disconnected when the connection part always works nor do I understand why I can step thru the code and it works but running normally does not.
Any ideas?
[ul]
[li]Declares a new socket[/li]
[li]Does a BeginConnect to connect to server (waits for connection)[/li]
[li]Sends data to the server (waits for send to complete)[/li]
[li]Receives a response from the server (waits for response to complete)[/li]
[li]Shuts down the socket and closes it[/li]
[/ul]
This works the first time I call the method. However, subsequent calls do not work. I get an error when data is sent: "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"
Sometimes the send will go through but I'll get the above error on the recieve part.
Now the strange thing is that if I step thru the code using F8, it works every time. When I run the code normally it will give me the error.
I don't know why the socket is disconnected when the connection part always works nor do I understand why I can step thru the code and it works but running normally does not.
Any ideas?