Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Can multi-app listen on the same socket port
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.clr.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

optman
i need to receive udp datagram on port 1900,
but the port is in used by other application.

the code :

new UdpClient(1900)

fail!

so ,what should i do ?

please help me ,thank in advance.

Reply to this message...
Vote that this is a GOOD answer...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
Michael Giagnocavo [MVP] (VIP)
If you bind to a specific IP and the other app has bound to a
non-specific IP, then you should be able to get it. Otherwise, you
could shutdown the app that is listening.
-mike
MVP

"optman" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
optman
I did it! just set socket option with ReuseAddress!

....

IPAddress groupAddress = IPAddress.Parse("239.255.255.250");

Socket Listener = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);

Listener.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress,
1);

Listener.Bind(new IPEndPoint(IPAddress.Any,1900));

MulticastOption multicastOption = new MulticastOption(groupAddress);
Listener.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.AddMembership,
multicastOption);

....

no need to shutdown other app ,actually i can't shut it down!

"Michael Giagnocavo [MVP]" <Click here to reveal e-mail address> дÈëÏûÏ¢ÐÂÎÅ
:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Net.IPAddress
System.Net.IPEndPoint
System.Net.Sockets.AddressFamily
System.Net.Sockets.MulticastOption
System.Net.Sockets.ProtocolType
System.Net.Sockets.Socket
System.Net.Sockets.SocketOptionLevel
System.Net.Sockets.SocketOptionName
System.Net.Sockets.SocketType
System.Net.Sockets.UdpClient




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734