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

Posted on 2006-05-09
Last Modified: 2012-05-05
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.

Question by:butterhook
    LVL 2

    Accepted Solution

    use non blocking sockets
    LVL 1

    Author Comment

    Thanks for your comment. I will try combining Socket.BeginSendFile and using wait handles today and see how I get on.
    LVL 1

    Author Comment

    Any pointers as to why the exception is occurring?
    LVL 1

    Author Comment

    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.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now