Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

DatagramSocket hangs for around 2 seconds when call close()

New Here ,
Mar 06, 2018 Mar 06, 2018

To replicate is easy

var datagram:DatagramSocket = new DatagramSocket();

datagram.bind();

datagram.receive();

var startTime:int = getTimer();

datagram.close();

trace("Time:", getTimer()-startTime);

Result: around 2001-2080

How to avoid this blocking?

Platform: Windows 7/10 Desktop

266
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2018 Mar 15, 2018

Hi there.

I tested this on macOS targeting AIR 28 for Desktop and received Time: 124:

I don't have access to a Windows system at the moment but will later today. Are there any other parameters regarding the FLA we should know about when testing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 15, 2018 Mar 15, 2018

I have also tested on macOS is exaclt 122-124ms/20-22ms

Even time consuming is less, still not acceptable for a function which only release a local port bind with nothing return?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 23, 2018 Mar 23, 2018
LATEST

I have found some looks very like the problem in crossbridge on github

crossbridge/javanet.c at f8c6eff42a2936d66c5a7aa1d5fbc35379985fb5 · adobe-flash/crossbridge · GitHub

_javanet_close:

while(error == TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL);

I found this conversion:

TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL == EINTR

and

crossbridge/uthread_recvfrom.c at f8c6eff42a2936d66c5a7aa1d5fbc35379985fb5 · adobe-flash/crossbridge...

errno = EINTR in _recvfrom

crossbridge/javanet.c at f8c6eff42a2936d66c5a7aa1d5fbc35379985fb5 · adobe-flash/crossbridge · GitHub

TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT (fd, optval, result);

here just setup timeout for recvfrom

If the value are match, the case I describe must happen if these code are relevant.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines