1

I have a .net 2.0 application that uses the System.Net.Sockets Send() method to send data at regular intervals e.g. every minute. Essentially it is a socket server. Most of the time there will be no clients connected to receive this data but occasionally a user will run an app which will connect to monitor the data that is being sent at regular intervals. At each interval the most I will ever send will be about 1024 bytes with most messages being much smaller.

My question is what impact on system resources does calling Send() every minute with no one to receive it have? Will this eventually eat up all my memory? I have read that the windows sockets are based on Berkeley Sockets which creates a file descriptor. Is there some low level Standard Output (stdout) being performed and the data that does not get received simply goes into a black hole?

1 Answer 1

1

what impact on system resources does calling Send() every minute with no one to receive it have?

Should be none - it should throw an error because the socket isn't open.

Will this eventually eat up all my memory?

No, it should simply throw an error.

Is there some low level Standard Output (stdout) being performed and the data that does not get received simply goes into a black hole?

The data is indeed thrown away, and if you're paying attention you'll see the error.

You should first check to see if the socket is open before sending. If no one is connected, don't send. One extra if statement.

-Adam

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I will add the code to see if anyone is connected. I assumed the data was being thrown away because in my tests it would just send and it did not throw an exception and my process mem usage did not go up.
No exception? Interesting... Now I'm going to have to run some tests. Good luck with your project!
If I get some time this weekend I will set up a test. If it repeats itself I will post the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.