To better understand how the .NET networking part works, I'm going through the reference source of the TcpListener( Documentation , Reference Source ) class. What caught my attention is that it owns the object implementing IDisposable (Socket) but does not implement IDisposable itself. Is there a reason for this?
Because when you use the IPEndPoint
based constructor , the TcpListener
doesn't own the socket. It would be very rude to dispose of said socket if you planned on reusing said IPEndPoint
object
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.