Forum Xamarin.Android

Problem reusing IPEndpoint (Address already in use)

tomjonztomjonz DEMember
edited December 2014 in Xamarin.Android


I would like to create a listner AND a client socket on the same address/port for TCP hole punching.

int PORT = 54375;

// Server Socket

Socket ListenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

ListenSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);

ListenSocket.Bind(new IPEndPoint(IPAddress.Any, PORT));


// Client Socket

Socket ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

ClientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

ClientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);

ClientSocket.Bind(new IPEndPoint(IPAddress.Any, PORT));

... and on "Bind" I get the Exception "Address already in use". This works very well in Windows.


  • tomjonztomjonz DEMember

    No idea? Is this a Mono bug? Is there a Workaround for this Problem?

  • tomjonztomjonz DEMember
    edited December 2014

    I cannot believe, that nobody know this binding Problem or can reproduce it? Bug?

  • tomjonztomjonz DEMember

    Holiday is over and no one from Xamarin know this Problem? So I have to finish my trial period and switch to Java?

Sign In or Register to comment.