You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
},"Getting SocketOptionName.DropMembership should have thrown an exception");
41
+
42
+
Assert.True((SocketType)testSocket.GetSocketOption(SocketOptionLevel.Socket,SocketOptionName.Type)==socketType,"Getting SocketOptionName.Type returned a different type.");
43
+
44
+
testSocket?.Close();
45
+
}
46
+
47
+
[TestMethod]
48
+
publicvoidSocketLinger()
49
+
{
50
+
SocketTypesocketType=SocketType.Stream;
51
+
52
+
SockettestSocket=new(
53
+
AddressFamily.InterNetwork,
54
+
socketType,
55
+
ProtocolType.Tcp);
56
+
57
+
// TODO
58
+
// connect to endpoint
59
+
60
+
// get linger option
61
+
//Assert.IsType(typeof(bool), testSocket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger), "SocketOptionName.DontLinger should return a bool.");
Copy file name to clipboardExpand all lines: nanoFramework.System.Net/Sockets/Socket.cs
+37-16Lines changed: 37 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -869,6 +869,8 @@ public int ReceiveFrom(byte[] buffer, ref EndPoint remoteEP)
869
869
/// <para><see cref="Socket"/> options determine the behavior of the current <see cref="Socket"/>. For an option with a Boolean data type, specify a nonzero value to enable the option, and a
870
870
/// zero value to disable the option. For an option with an integer data type, specify the appropriate value. <see cref="Socket"/> options are grouped by level of protocol support.
871
871
/// </para>
872
+
/// For <see cref="SocketOptionName.Linger"/> option the <paramref name="optionValue"/> it's the number of seconds that the socket will linger before closing the connection.
873
+
/// To disable socket linger call <see cref="SetSocketOption(SocketOptionLevel,SocketOptionName,bool)"/> with <see cref="SocketOptionName.DontLinger"/> and setting it to <see langword="true"/>.
@@ -931,32 +933,33 @@ public void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName opti
931
933
/// <param name="optionLevel">One of the <see cref="SocketOptionLevel"/> values.</param>
932
934
/// <param name="optionName">One of the <see cref="SocketOptionName"/> values.</param>
933
935
/// <returns>
934
-
/// An object that represents the value of the option. When the optionName parameter is set to <see cref="SocketOptionName.Linger"/> the return value is an instance of the LingerOption
935
-
/// class. When optionName is set to <see cref="SocketOptionName.AddMembership"/> or <see cref="SocketOptionName.DropMembership"/>, the return value is an instance of the MulticastOption class. When optionName is
936
-
/// any other value, the return value is an integer.
936
+
/// <para>/// An object that represents the value of the option.</para>
937
+
/// <para>
938
+
/// When the <paramref name="optionName"/> parameter is set to <see cref="SocketOptionName.Linger"/> the return value is an <see cref="int"/> with the value in seconds that the socket will linger after close.
939
+
/// To check if linger is enabled for the socket the <see cref="SocketOptionName.DontLinger"/> option should be queried.
940
+
/// </para>
941
+
/// <para>
942
+
/// When optionName is set to <see cref="SocketOptionName.ExclusiveAddressUse"/>, <see cref="SocketOptionName.DontLinger"/>, <see cref="SocketOptionName.AcceptConnection"/>, <see cref="SocketOptionName.Broadcast"/> or <see cref="SocketOptionName.KeepAlive"/>, the return value is <see cref="bool"/>.
943
+
/// </para>
944
+
/// <para>
945
+
/// When optionName is any other value, the return value is an integer.
946
+
/// </para>
937
947
/// </returns>
938
-
/// <remarks>
939
-
/// <see cref="Socket"/> options determine the behavior of the current <see cref="Socket"/>. Use this overload to get the <see cref="SocketOptionName.Linger"/>, <see cref="SocketOptionName.AddMembership"/>, and <see cref="SocketOptionName.DropMembership"/> options.
940
-
/// For the <see cref="SocketOptionName.Linger"/> option, use <see cref="Socket"/> for the optionLevel parameter. For <see cref="SocketOptionName.AddMembership"/> and <see cref="SocketOptionName.DropMembership"/>, use <see cref="SocketOptionLevel.IP"/>. If you want to set the value of any of
941
-
/// the options listed above, use the <see cref="SetSocketOption(SocketOptionLevel, SocketOptionName, Int32)"/> method.
942
-
/// </remarks>
948
+
/// <exception cref="NotSupportedException">When using an <see cref="SocketOptionName"/> that can't be retrieved.</exception>
0 commit comments