Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. felixc4d
    F
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    felixc4d

    @felixc4d

    0
    Reputation
    2
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    felixc4d Unfollow Follow

    Latest posts made by felixc4d

    • RE: UDP Receive AioBuffer Size limited to 1024 bytes, how to increase it? [C4D SDK]

      Hi @ferdinand,

      Thank you for the detailed explanation. I will try to implement the UDP server using the basic SOCKET from winsock library.

      While digging into the SDK, I found that the AioServiceRef do have a function called RegisterReader, but I could not manage to successfully use it and there is no example code that I can learn from.

      SO I wonder:

      1. Is it a good way to using RegisterReader function combined with the customized low level SOCKET? So that I can bypass the limitation of 1024 bytes?
      2. If so, can you please provide some example code of how to use the RegisterReader ? Suppose that I have the following code:
      // I am not sure if I should create a new Reader Class to override the NotifyForRead function
      class AioReaderRefNew : public maxon::AioReaderRef
      {
      public:
          AioReaderRefNew() = default;
      
          maxon::Result<void> NotifyForRead(maxon::SocketT socket, maxon::Result<void> result) {
              iferr_scope;
              DiagnosticOutput("NotifyForRead");
              return maxon::OK;
          }
      };
      
      AioReaderRefNew udpServerReader;
      
      mSocket  = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
      
      g_ioService = maxon::AioServiceRef::Create() iferr_return;
      
      if (g_ioService.RegisterReader(mSocket, udpServerReader) == maxon::OK);
      
      g_ioService.Start() iferr_return;
      

      Apparaently the above did not successfully start the aioservice, so may be you could fix it?

      Thank you

      posted in Cinema 4D SDK
      F
      felixc4d
    • UDP Receive AioBuffer Size limited to 1024 bytes, how to increase it? [C4D SDK]

      I am developing a plugin that connect to an external APP via TCP/UDP connection. I managed using the TCP/UDP interface provided in the C4D SDK [TCP ref] [UDP ref].

      The TCP connection has worked fine but the UDP connection has encountered the following problem:

      1. the received message buffer is limited to 1024 bytes while the entire message is over 5000 bytes (we cannot reduce the buffer size or split the buffer to chunks as it was set in the external APP)

      2. I've dived deep into the sdk source files and cannot find where to change the AioBuffer size, I know that you can specify the receive buffer size with the setsockopt, but how do I pass in the mSocket parameter from NetworkUdpInterface?

      	setsockopt(mSocket, SOL_SOCKET, SO_RCVBUF, (char*)&bufSize, sizeof(bufSize));
      

      Here is my example code

      maxon::Result<void> NetworkManager::CreateUDPConnection() {
      	// create AioServiceRef
      	iferr_scope;
      	g_ioService = maxon::AioServiceRef::Create() iferr_return;
      	g_ioService.Start() iferr_return;
      
      	// create and start server
      	auto localAddr = maxon::NetworkIpAddrPort(maxon::WILDCARD_IPV4_ADDRESS, mLocalPort);
      	
      // set the callback
      	UdpRecvHandler = UdpRecvCompHandler::CreateByReference(this,
      		static_cast<maxon::Result<void>(NetworkManager::*)(maxon::Result<void>, maxon::AioBuffer, maxon::NetworkIpAddrPort)>(&NetworkManager::UDPCallback));
      	
      	g_udpServer = maxon::NetworkUdpInterface::CreateUdpServer(localAddr, std::move(UdpRecvHandler), g_ioService) iferr_return;
      
      	g_udpServer.Start() iferr_return;
      	return maxon::OK;
      }
      
      maxon::Result<void> NetworkManager::UDPCallback(maxon::Result<void> result, maxon::AioBuffer receivedData, maxon::NetworkIpAddrPort sender)
      {
      	iferr_scope;
      	const maxon::String message{ receivedData };
      DiagnosticOutput("UDPCallback Message: msg Len @, MemSize @, CapCount @ |  @", message.GetLength(), receivedData.GetMemorySize(), receivedData.GetCapacityCount(),message);
      // ...codes that handles the message
      	return maxon::OK;
      }
      

      Here is the debug log shows that the message is only 1024 bytes

      UDPCallback Message: msg Len 1024, MemSize 1048, CapCount 1024 |
      

      Please help~ Any kind of hint is welcome~

      posted in Cinema 4D SDK c++ windows
      F
      felixc4d