x


Iphone UDP Server Discovery

I'm trying to get unity to send UDP packages for Direct Server Discovery. It seems to work in the editor, but fails on the iPhone 3G.

There's an example on the main page: http://download.unity3d.com/support/resources/files/MultiplayerTutorial.pdf

But it looks like it's quit old, probably even outdated.

When sending via UDPClient I get an SocketException: "The requested address is not valid in this context"

One of the variations I tried:

if (m_Server == null)
{
    m_Server = new UdpClient();//m_Port, AddressFamily.InterNetwork);
    //m_Server.EnableBroadcast = true;

    //var broadcastIp = new IPEndPoint(IPAddress.Broadcast, m_Port);
    //Debug.Log("NetworkManager.ServerProc() - " + broadcastIp + " connecting");
    //m_Server.Connect(broadcastIp);
    //Debug.Log("NetworkManager.ServerProc() - Connected");
}

var encode = new ASCIIEncoding();
var data = m_MySelf.Serialize();
var sendData = encode.GetBytes(data);
try
{
    m_Server.Send(sendData, sendData.Length, broadcastEndPoint);
    Debug.Log("NetworkManager.ServerProc() - Sent Packet: " + data);
}
catch (SocketException ex)
{
    Debug.Log("NetworkManager.ServerProc() - Send Error: " + ex);
    Debug.Log("NetworkManager.ServerProc() - Error Code: " + ex.SocketErrorCode);
}
catch (Exception ex)
{
    Debug.Log("NetworkManager.ServerProc() - Send Error: " + ex);
}
more ▼

asked Mar 24 '11 at 07:44 PM

Mostley gravatar image

Mostley
46 3 4 6

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1999
x708
x30
x10
x3

asked: Mar 24 '11 at 07:44 PM

Seen: 1084 times

Last Updated: Mar 24 '11 at 07:44 PM