зеркало из https://github.com/mono/mail-archives.git
153 строки
5.2 KiB
HTML
153 строки
5.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-bugs] [Bug 643475] Socket.ExclusiveAddressUse not working with UDP
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20643475%5D%20Socket.ExclusiveAddressUse%20not%20working%0A%09with%20UDP&In-Reply-To=bug-643475-28286%40http.bugzilla.novell.com/">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="104428.html">
|
|
<LINK REL="Next" HREF="104460.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-bugs] [Bug 643475] Socket.ExclusiveAddressUse not working with UDP</H1>
|
|
<B>bugzilla_noreply at novell.com</B>
|
|
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20643475%5D%20Socket.ExclusiveAddressUse%20not%20working%0A%09with%20UDP&In-Reply-To=bug-643475-28286%40http.bugzilla.novell.com/"
|
|
TITLE="[Mono-bugs] [Bug 643475] Socket.ExclusiveAddressUse not working with UDP">bugzilla_noreply at novell.com
|
|
</A><BR>
|
|
<I>Mon Oct 4 07:14:06 EDT 2010</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="104428.html">[Mono-bugs] [Bug 643475] New: Socket.ExclusiveAddressUse not working with UDP
|
|
</A></li>
|
|
<LI>Next message: <A HREF="104460.html">[Mono-bugs] [Bug 643475] Socket.ExclusiveAddressUse not working with UDP
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#104429">[ date ]</a>
|
|
<a href="thread.html#104429">[ thread ]</a>
|
|
<a href="subject.html#104429">[ subject ]</a>
|
|
<a href="author.html#104429">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>
|
|
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=643475">https://bugzilla.novell.com/show_bug.cgi?id=643475</A>
|
|
|
|
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=643475#c1">https://bugzilla.novell.com/show_bug.cgi?id=643475#c1</A>
|
|
|
|
|
|
--- Comment #1 from Antonio Anzivino <<A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">djechelon at fastwebnet.it</A>> 2010-10-04 11:14:05 UTC ---
|
|
We just submitted a workaround into our code repository
|
|
|
|
<A HREF="http://logbus-ng.svn.sourceforge.net/viewvc/logbus-ng?view=revision&revision=396">http://logbus-ng.svn.sourceforge.net/viewvc/logbus-ng?view=revision&revision=396</A>
|
|
|
|
Everyone experiencing the same problem could use our approach: scan the list of
|
|
running UDP listeners via IPGlobalProperties
|
|
|
|
For each port in the range of known ports, try to find it in the active sockets
|
|
list ;-)
|
|
|
|
#if MONO
|
|
IPEndPoint[] eps =
|
|
IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners();
|
|
#endif
|
|
for (int i = START_PORT; i <= END_PORT; i++)
|
|
{
|
|
#if MONO
|
|
//Workaround to Mono bug 64375
|
|
bool found = false;
|
|
for (int c = 0; c < eps.Length; c++)
|
|
{
|
|
if (eps[c].Port == i &&
|
|
(eps[c].Address.Equals(IPAddress.Any) || eps[c].Address.Equals(localIp)))
|
|
{
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found)
|
|
{
|
|
Socket socket = new Socket(AddressFamily.InterNetwork,
|
|
SocketType.Dgram, ProtocolType.Udp);
|
|
socket.Bind(new IPEndPoint(localIp, i));
|
|
_client = new UdpClient { Client = socket };
|
|
break;
|
|
}
|
|
#else
|
|
try
|
|
{
|
|
Socket socket = new Socket(AddressFamily.InterNetwork,
|
|
SocketType.Dgram, ProtocolType.Udp) { ExclusiveAddressUse = true };
|
|
socket.Bind(new IPEndPoint(localIp, i));
|
|
|
|
_client = new UdpClient { Client = socket };
|
|
break;
|
|
}
|
|
catch (SocketException)
|
|
{ }
|
|
#endif
|
|
}
|
|
|
|
Adapt this code to your needs and voilà
|
|
|
|
--
|
|
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
|
|
------- You are receiving this mail because: -------
|
|
You are the QA contact for the bug.
|
|
You are the assignee for the bug.
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="104428.html">[Mono-bugs] [Bug 643475] New: Socket.ExclusiveAddressUse not working with UDP
|
|
</A></li>
|
|
<LI>Next message: <A HREF="104460.html">[Mono-bugs] [Bug 643475] Socket.ExclusiveAddressUse not working with UDP
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#104429">[ date ]</a>
|
|
<a href="thread.html#104429">[ thread ]</a>
|
|
<a href="subject.html#104429">[ subject ]</a>
|
|
<a href="author.html#104429">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
|
|
mailing list</a><br>
|
|
</body></html>
|