|
-
November 7th, 2008, 07:04 AM
#1
Can two threads write to a NetworkStream simultaneously?
Just wondering if anyone knows about any syncronization required for NetworkStream. MSDN says that read and write are supported simultaneously, but i'm in a situation where I receive a message over an NS, execute a db query and send a response. If the db is being slow, the client times out. To prevent this, a keep-alive message should be sent at most, every 30 seconds.
I plan to implement a timer and put all current sockets in a dictionary<socket, int>. Every 1000 milliseconds the dictionary value for each socket is incremented, and any that become greater than 25 will have a keep-alive sent and the value will be reset. Send will probably need to be be async..
I'm now asking what happens if my keep-alive thread sends a byte[] at the same time that the db thread sends a byte[]? Anyone know if the buffers intermingle or are they sent in order that they were submitted?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|