Skip to content

Commit

Permalink
Merge pull request zeromq#711 from IEliminator/master
Browse files Browse the repository at this point in the history
Minor changes but vital for managing sudden network change…
  • Loading branch information
somdoron authored Nov 8, 2017
2 parents 02b7244 + 1c72e56 commit b7800ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/NetMQ/Core/Patterns/Utils/ArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static T[] Resize<T>([NotNull] this T[] src, int size, bool ended)

public static void Swap<T>([NotNull] this List<T> items, int index1, int index2) where T : class
{
if (index1 == index2)
if (index1 == index2)
return;

T item1 = items[index1];
Expand Down
14 changes: 13 additions & 1 deletion src/NetMQ/NetMQBeacon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,19 @@ private void OnPipeReady(object sender, NetMQSocketEventArgs e)

private void SendUdpFrame(NetMQFrame frame)
{
m_udpSocket.SendTo(frame.Buffer, 0, frame.MessageSize, SocketFlags.None, m_broadcastAddress);
try
{
m_udpSocket.SendTo(frame.Buffer, 0, frame.MessageSize, SocketFlags.None, m_broadcastAddress);
}
catch (SocketException ex)
{
if (ex.SocketErrorCode != SocketError.AddressNotAvailable) { throw; }

// Initiate Creation of new Udp here to solve issue related to 'sudden' network change.
// On windows (7 OR 10) incorrect/previous ip address might still exist instead of new Ip
// due to network change which causes crash (if no try/catch and keep trying to send to incorrect/not available address.
// This approach would solve the issue...
}
}

private NetMQFrame ReceiveUdpFrame(out string peerName)
Expand Down

0 comments on commit b7800ba

Please sign in to comment.