Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Oculus Go:UDPClient is not working.

shogo.ajinashogo.ajina Posts: 2
edited July 2018 in Unity Development
Dear community,

 I attempted to receive UDP packets using the following code.
However, the following exceptions are occurring when I launch the application on oculus go.
Is there anyone in the same situation?
Please tell me the solution.

Unity 2018.1.8f1

System.Threading.ThreadAbortException: Thread was being aborted
  at (wrapper managed-to-native) System.Net.Sockets.Socket:RecvFrom_internal (intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&)
  at System.Net.Sockets.Socket.ReceiveFrom_nochecks_exc (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint& remote_end, Boolean throwOnError, System.Int32& error) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.Socket.ReceiveFrom_nochecks (System.Byte[] buf, Int32 offset, Int32 size, SocketFlags flags, System.Net.EndPoint& remote_end) [0x00000] in <filename unknown>:0 
  at System.Net.Sockets.Socket.ReceiveFrom (System.Byte[] buffer, System.Net.EndPoint& remoteEP) [0x00000] in <filename unknown>:0 

Source Code:
using UnityEngine;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

public class UDPReceive : MonoBehaviour
    int LOCA_LPORT = 22222;
    static UdpClient udp;
    Thread thread;

    void Start ()
        udp = new UdpClient(LOCA_LPORT);
        udp.Client.ReceiveTimeout = 1000;
        thread = new Thread(new ThreadStart(ThreadMethod));

    void Update ()

    void OnApplicationQuit()

    private static void ThreadMethod()
            try {
                IPEndPoint remoteEP = null;
                byte[] data = udp.Receive(ref remoteEP);  // The exception raises here.
                string text = Encoding.ASCII.GetString(data);
            } catch(Exception ex) {

Best Regards,

Best Answer

  • shogo.ajinashogo.ajina Posts: 2
    edited July 2018 Accepted Answer
    This problem is has been resolved.
    It seems to be bad that I handle UDPClient from thread not main.
    It worked after modifying as follows. 

    using UnityEngine;
    using System.Collections;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;
    using System.Threading;



  • pascalpmpascalpm Posts: 1
    private void ReceiveCallback(IAsyncResult ar)''private void ReceiveCallback()' should read '
Sign In or Register to comment.