By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,987 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,987 IT Pros & Developers. It's quick & easy.

TcpClient.GetStream can return null ?!?!?

P: n/a
Has anyone seen this happen?

I have seen it on a system that is making lots and lots of short lived connections. At this point I'm not sure of the high water mark for the number of connections. Maybe I'm just running out of some kind of resource and the .NET framework is not doing a good job at reporting it.

Any other ideas on what might cause it?

Thanks.

ti**************@mindspringXXX.com

(Note remove the XXX's to email me directly.)
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Apr 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello, Tim!

TL> I have seen it on a system that is making lots and lots of short lived
TL> connections. At this point I'm not sure of the high water mark for the
TL> number of connections. Maybe I'm just running out of some kind of
TL> resource and the .NET framework is not doing a good job at reporting
TL> it.

TL> Any other ideas on what might cause it?

Strange TcpClient.GetStream() can't return null in normal conditions.

IMO this may happen in multithreaded environment, when TcpClient.Dispose is called, while another thread
is calling TcpCleint.GetStream().

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 6 '06 #2

P: n/a
| IMO this may happen in multithreaded environment, when TcpClient.Dispose
is called, while another thread
| is calling TcpCleint.GetStream().

Agree. Dispose is also called by Close(), so if thread1 called Close() and
thread2 called GetStream() and a thread switch was called at a certain
time, it looks like it could happen. The odds look better to win lottery,
but I guess it could happen. It is marked at not thread safe, so you should
sync access with a lock. It would be interesting to see a small code sample
that catches this error happening.
--
wjs
Apr 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.