extend System.Net.Sockets.ProtocolType

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I want to extend System.Net.Sockets.ProtocolType to IPinIP protocol, how can
i do that.
Do i have to make new class or enum stuct for this type ?

regards
 
centrino,

You can't really extend an existing enumeration (unless you have the
source code).

The best you can do is define the value for the IPinIP protocol as a
constant, or a value in a new enumeration. Then, pass that value to the
Socket constructor, but cast it to the ProtocolType enumeration type. When
casting an int or enumeration to another enumeration type, there is no check
to make sure the value is part of the enumeration.

Hope this helps.
 
Hi Nicholas,

I can't imagine well how it work .
My IPv4 class hat the attribute TransportProtocol of
System.Net.Sockets.ProtocolType

IPv4 ip = new IPv4();

-> ip.TransportProtocol = ?

Could U give me some example ?

Thanks !


Nicholas Paldino said:
centrino,

You can't really extend an existing enumeration (unless you have the
source code).

The best you can do is define the value for the IPinIP protocol as a
constant, or a value in a new enumeration. Then, pass that value to the
Socket constructor, but cast it to the ProtocolType enumeration type. When
casting an int or enumeration to another enumeration type, there is no check
to make sure the value is part of the enumeration.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

centrino said:
hi,

I want to extend System.Net.Sockets.ProtocolType to IPinIP protocol, how
can
i do that.
Do i have to make new class or enum stuct for this type ?

regards
 
Back
Top