Link to home
Start Free TrialLog in
Avatar of butterhook
butterhookFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Can a socket be Sending and Receiving at the same time?

Hi Experts

I have a problem that is really getting on my nerves now and would really appreciate some help.

Two apps - one is a front end client, the other is a server. They are communicating via sockets.

At some stage the user will transmit a load of files sequentially from the client to the server. I am looping over the blocking method Socket.SendFile for this.

When the server receives the files it sends a status notification message to the client.

The client receives the status notification messages asynchronously in a different thread to the one used for sending files.

The problem is I keep getting the exception: A blocking operation was interrupted by a call to WSACancelBlockingCall at some arbitrary point the n'th iteration of the SendFile command.

I am assuming the socket cannot be sending and receiving at the same time, although any other suggestions would be welcome.

Butterhook
ASKER CERTIFIED SOLUTION
Avatar of MasterThai
MasterThai

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of butterhook

ASKER

Thanks for your comment. I will try combining Socket.BeginSendFile and using wait handles today and see how I get on.
Any pointers as to why the exception is occurring?
Although I have now solved the problem by non blocking sockets as suggested by MasterThai I'd still like to know under what circumstances the blocking operation would be interrupted by a call to WSACancelBlockingCall, and also in response to my original question which was "Can a blocked socket be sending and receiving at the same time? If it is blocked on send does that mean it cannot receive on another thread?"

I will still award the points to MasterThai in due course but I would appreciate a more full explanation.

Thanks!

Butterhook