public OscServer(int port, int bufferSize = 4096) { if (PortToServer.ContainsKey(port)) { Debug.LogError($"port {port} is already in use, cannot start a new OSC Server on it"); return; } k_SingleCallbackToPair.Clear(); AddressSpace = new OscAddressSpace(); m_ReadBuffer = new byte[bufferSize]; m_BufferHandle = GCHandle.Alloc(m_ReadBuffer, GCHandleType.Pinned); m_BufferPtr = (byte *)m_BufferHandle.AddrOfPinnedObject(); Parser = new OscParser(m_ReadBuffer); Port = port; m_Socket = new OscSocket(port) { Server = this }; Start(); }
public OscServer(int port, int bufferSize = 4096) { if (PortToServer.ContainsKey(port)) { Debug.LogError($"port {port} is already in use, cannot start a new OSC Server on it"); return; } k_SingleCallbackToPair.Clear(); AddressSpace = new OscAddressSpace(); m_ReadBuffer = new byte[bufferSize]; m_BufferHandle = GCHandle.Alloc(m_ReadBuffer, GCHandleType.Pinned); m_BufferPtr = (byte *)m_BufferHandle.AddrOfPinnedObject(); Parser = new OscParser(m_ReadBuffer); Port = port; m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) { ReceiveTimeout = int.MaxValue }; m_Thread = new Thread(Serve); Start(); }