Skip to main content
Known Participant
March 7, 2018
Question

DatagramSocket hangs for around 2 seconds when call close()

  • March 7, 2018
  • 3 replies
  • 304 views

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

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Known Participant
March 23, 2018

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 · GitHub

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.

Joseph Labrecque
Community Expert
Community Expert
March 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?

Known Participant
March 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?