Skip to content

Commit f67be34

Browse files
Extract a method, remove dead code
1 parent 3df1c2a commit f67be34

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

projects/client/RabbitMQ.Client/src/client/impl/SocketFrameHandler.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public SocketFrameHandler(AmqpTcpEndpoint endpoint,
8585
{
8686
Endpoint = endpoint;
8787

88-
if (Socket.OSSupportsIPv6 && endpoint.AddressFamily != AddressFamily.InterNetwork)
88+
if (ShouldTryIPV6(endpoint))
8989
{
9090
try {
9191
m_socket = ConnectUsingIPv6(endpoint, socketFactory, connectionTimeout);
@@ -155,12 +155,10 @@ public int ReadTimeout
155155
m_socket.ReceiveTimeout = value;
156156
}
157157
}
158-
#pragma warning disable 0168
159-
catch (SocketException _)
158+
catch (SocketException)
160159
{
161160
// means that the socket is already closed
162161
}
163-
#pragma warning restore 0168
164162
}
165163
}
166164

@@ -181,13 +179,6 @@ public void Close()
181179
{
182180
try
183181
{
184-
try
185-
{
186-
187-
} catch (ArgumentException)
188-
{
189-
// ignore, we are closing anyway
190-
};
191182
m_socket.Close();
192183
}
193184
catch (Exception)
@@ -264,6 +255,11 @@ public void Flush()
264255
}
265256
}
266257

258+
private bool ShouldTryIPV6(AmqpTcpEndpoint endpoint)
259+
{
260+
return (Socket.OSSupportsIPv6 && endpoint.AddressFamily != AddressFamily.InterNetwork)
261+
}
262+
267263
private ITcpClient ConnectUsingIPv6(AmqpTcpEndpoint endpoint,
268264
Func<AddressFamily, ITcpClient> socketFactory,
269265
int timeout)

0 commit comments

Comments
 (0)