TCP tranmission problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am programming on message tranmission via TCP socket
I am sure that the connection between server and client is established.
It can receive messages from server.
However, during running the following command to send a message from client
to server:
"sock.Send( byteDateLine, byteDateLine.Length, 0 );"
an exception is caught:
"InvalidOperationException"
What's the problem?
Please help me
 
Did you set the socket to non-blocking mode? Socket object in CF does not
support synchronous non-blocking operations. You will need to use
BeginSend/EndSend
 
I am using asynchronous mode

Alex Feinman said:
Did you set the socket to non-blocking mode? Socket object in CF does not
support synchronous non-blocking operations. You will need to use
BeginSend/EndSend
 
No, you are not. If you were using asynchronous mode, you would be calling
BeginSend/EndSend. As it is your code shows using Send, which is
synchronous. If elsewhere in your code you use sock.Blocking = false, it
will cause the InvalidOperationException. Change sock.Blocking to true and
use Begin/End if you need non-blocking operation
 
Back
Top