Multimobile Development: Building Applications for any Smartphone
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...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
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




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734