[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 659
  • Last Modified:

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
0
butterhook
Asked:
butterhook
  • 3
1 Solution
 
MasterThaiCommented:
use non blocking sockets
0
 
butterhookAuthor Commented:
Thanks for your comment. I will try combining Socket.BeginSendFile and using wait handles today and see how I get on.
0
 
butterhookAuthor Commented:
Any pointers as to why the exception is occurring?
0
 
butterhookAuthor Commented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now