I am trying to find a solution for this issue in Android Studio
Emulator: socketTcpLoopbackClientFor: error: fd 63080 above FD_SETSIZE (32768)
I found someone facing kind of similar issue few years ago in another question.
Basically it was argued:
Your process has too many file descriptor or sockets open, and when the OS limit is reached, your app gets killed.
It is very unlikely that your app is legitimately using up all the resources, it is most likely a leak. You most probably miss a Close() call for a socket or a file resource.
My issues isn't related to FortiFy like this one but the idea seems quite reasonable: somehow my application is missing a close somewhere. Well, I can't find where I forgot.
Here is the entire application:
package com.mycomp.appfirestore
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import com.mycomp.appfirestore.data.service.Endpoint
import com.mycomp.appfirestore.data.service.NetworkUtils
import com.mycomp.appfirestore.model.Posts
import com.mycomp.appfirestore.model.Transfer
import kotlinx.android.synthetic.main.activity_main.*
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.net.URL
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val btnTransfer=findViewById(R.id.btnTransfer) as Button
val textViewTransfer=findViewById(R.id.textViewTransfer) as TextView
btnTransfer.setOnClickListener {
postTransfer()
}
}
fun postTransfer() {
val retrofitClient = NetworkUtils
.getRetrofitInstance("http://192.168.15.13:8080/")
val endpoint = retrofitClient.create(Endpoint::class.java)
val transfer = Transfer("Demetrio","Jimis","100","","")
val callback = endpoint.postTransfer(transfer)
callback.enqueue(object : Callback<Transfer> {
override fun onFailure(call: Call<Transfer>, t: Throwable) {
Toast.makeText(baseContext, t.message, Toast.LENGTH_SHORT).show()
}
override fun onResponse(call: Call<Transfer>, response: Response<Transfer>) {
textViewTransfer.text = response.body().toString()
}
})
}
}
Assuming there is no connection hold in my application here are other useful info.
And my straight question is: is it possible either to increase FD_SETSIZE or limit the amount demanded by Emulator?
Microsoft Windows [versão 10.0.18363.836]
(c) 2019 Microsoft Corporation. Todos os direitos reservados.
C:\Windows\system32>cd C:\Users\mycomp\AppData\Local\Android\Sdk\
C:\Users\mycomp\AppData\Local\Android\Sdk>cd platform-tools
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>adb devices -l
List of devices attached
emulator-5554 device product:sdk_gphone_x86_arm model:AOSP_on_IA_Emulator device:generic_x86_arm transport_id:1
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>adb shell ulimit -n
32768
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>adb shell ps
USER PID PPID VSZ RSS WCHAN ADDR S NAME
root 1 0 17440 1812 0 0 S init
root 2 0 0 0 0 0 S [kthreadd]
root 3 2 0 0 0 0 S [ksoftirqd/0]
root 5 2 0 0 0 0 S [kworker/0:0H]
root 7 2 0 0 0 0 S [rcu_preempt]
root 8 2 0 0 0 0 S [rcu_sched]
root 9 2 0 0 0 0 S [rcu_bh]
root 10 2 0 0 0 0 S [migration/0]
root 11 2 0 0 0 0 S [migration/1]
root 12 2 0 0 0 0 S [ksoftirqd/1]
root 14 2 0 0 0 0 S [kworker/1:0H]
root 16 2 0 0 0 0 S [migration/2]
root 17 2 0 0 0 0 S [ksoftirqd/2]
root 19 2 0 0 0 0 S [kworker/2:0H]
root 20 2 0 0 0 0 S [migration/3]
root 21 2 0 0 0 0 S [ksoftirqd/3]
root 23 2 0 0 0 0 S [kworker/3:0H]
root 24 2 0 0 0 0 S [netns]
root 27 2 0 0 0 0 S [perf]
root 383 2 0 0 0 0 S [khungtaskd]
root 384 2 0 0 0 0 S [writeback]
root 386 2 0 0 0 0 S [crypto]
root 387 2 0 0 0 0 S [bioset]
root 389 2 0 0 0 0 S [kblockd]
root 502 2 0 0 0 0 S [ata_sff]
root 522 2 0 0 0 0 S [md]
root 533 2 0 0 0 0 S [cfg80211]
root 649 2 0 0 0 0 S [kswapd0]
root 650 2 0 0 0 0 S [vmstat]
root 723 2 0 0 0 0 S [fsnotify_mark]
root 790 2 0 0 0 0 S [acpi_thermal_pm]
root 820 2 0 0 0 0 S [hwrng]
root 826 2 0 0 0 0 S [bioset]
root 827 2 0 0 0 0 S [bioset]
root 828 2 0 0 0 0 S [bioset]
root 830 2 0 0 0 0 S [bioset]
root 831 2 0 0 0 0 S [bioset]
root 832 2 0 0 0 0 S [bioset]
root 833 2 0 0 0 0 S [bioset]
root 834 2 0 0 0 0 S [bioset]
root 835 2 0 0 0 0 S [bioset]
root 836 2 0 0 0 0 S [bioset]
root 837 2 0 0 0 0 S [bioset]
root 838 2 0 0 0 0 S [bioset]
root 839 2 0 0 0 0 S [bioset]
root 840 2 0 0 0 0 S [bioset]
root 841 2 0 0 0 0 S [bioset]
root 842 2 0 0 0 0 S [bioset]
root 876 2 0 0 0 0 S [bioset]
root 879 2 0 0 0 0 S [bioset]
root 882 2 0 0 0 0 S [bioset]
root 885 2 0 0 0 0 S [bioset]
root 887 2 0 0 0 0 S [bioset]
root 891 2 0 0 0 0 S [bioset]
root 894 2 0 0 0 0 S [bioset]
root 897 2 0 0 0 0 S [bioset]
root 900 2 0 0 0 0 S [bioset]
root 905 2 0 0 0 0 S [bioset]
root 908 2 0 0 0 0 S [bioset]
root 911 2 0 0 0 0 S [bioset]
root 914 2 0 0 0 0 S [bioset]
root 918 2 0 0 0 0 S [bioset]
root 927 2 0 0 0 0 S [iscsi_eh]
root 947 2 0 0 0 0 S [scsi_eh_0]
root 948 2 0 0 0 0 S [scsi_tmf_0]
root 949 2 0 0 0 0 S [scsi_eh_1]
root 953 2 0 0 0 0 S [scsi_tmf_1]
root 1031 2 0 0 0 0 S [dm_bufio_cache]
root 1064 2 0 0 0 0 S [binder]
root 1102 2 0 0 0 0 S [ipv6_addrconf]
root 1125 2 0 0 0 0 S [deferwq]
root 1138 2 0 0 0 0 S [bioset]
root 1143 2 0 0 0 0 S [kdmflush]
root 1146 2 0 0 0 0 S [bioset]
root 1147 2 0 0 0 0 S [kverityd]
root 1148 2 0 0 0 0 S [bioset]
root 1150 2 0 0 0 0 S [ext4-rsv-conver]
root 1201 2 0 0 0 0 S [ext4-rsv-conver]
root 1202 1 4484 376 0 0 S init
root 1203 1 4228 380 0 0 S init
root 1204 1 4868 1072 0 0 S ueventd
root 1575 2 0 0 0 0 S [kworker/3:1H]
root 1579 2 0 0 0 0 S [kworker/1:1H]
root 1582 2 0 0 0 0 S [kworker/0:1H]
root 1584 2 0 0 0 0 S [kworker/2:1H]
logd 1587 1 20216 8444 0 0 S logd
system 1589 1 7560 3328 0 0 S servicemanager
system 1590 1 11496 4572 0 0 S hwservicemanager
root 1594 2 0 0 0 0 S [kauditd]
system 1595 1 8324 1880 0 0 S vndservicemanager
system 1597 1 11676 3368 0 0 S android.hardware.keymaster@3.0-service
root 1598 1 19360 5328 0 0 S vold
system 1639 1 8180 2296 0 0 S android.hidl.allocator@1.0-service
root 1640 1 8548 3336 0 0 S healthd
system 1641 1 17488 4068 0 0 S vr_hwc
audioserver 1642 1 25744 4324 0 0 S android.hardware.audio@2.0-service
audioserver 1643 1 9664 3028 0 0 S android.hardware.broadmycompradio@1.1-service
cameraserver 1644 1 25680 4908 0 0 S android.hardware.camera.provider@2.4-service
media 1645 1 11940 3012 0 0 S android.hardware.cas@1.0-service
system 1646 1 12024 3160 0 0 S android.hardware.configstore@1.1-service
media 1647 1 13568 3436 0 0 S android.hardware.drm@1.0-service
media 1648 1 13464 3596 0 0 S android.hardware.drm@1.1-service.clearkey
media 1649 1 16160 3192 0 0 S android.hardware.drm@1.1-service.widevine
system 1650 1 11748 3092 0 0 S android.hardware.gatekeeper@1.0-service
gps 1651 1 14208 3360 0 0 S android.hardware.gnss@1.0-service
system 1652 1 26376 8736 0 0 S android.hardware.graphics.allocator@2.0-service
system 1654 1 9444 2892 0 0 S android.hardware.health@2.0-service.goldfish
system 1655 1 9180 3052 0 0 S android.hardware.power@1.1-service.ranchu
system 1656 1 10908 3380 0 0 S android.hardware.sensors@1.0-service
wifi 1657 1 13344 3844 0 0 S android.hardware.wifi@1.0-service
root 1659 1 6992 1956 0 0 S qemu-props
audioserver 1660 1 58964 7184 0 0 S audioserver
root 1661 1 6248 2536 0 0 S lmkd
system 1663 1 11212 3472 0 0 S thermalserviced
logd 1664 1 7048 3136 0 0 S logcat
root 1751 2 0 0 0 0 S [kdmflush]
root 1752 2 0 0 0 0 S [bioset]
root 1753 2 0 0 0 0 S [kcryptd_io]
root 1755 2 0 0 0 0 S [kcryptd]
root 1756 2 0 0 0 0 S [dmcrypt_write]
root 1758 2 0 0 0 0 S [bioset]
root 1766 2 0 0 0 0 S [jbd2/dm-1-8]
root 1767 2 0 0 0 0 S [ext4-rsv-conver]
system 1773 1 122680 17548 0 0 S surfaceflinger
root 1774 1 1328276 73156 0 0 S zygote
cameraserver 1775 1 38124 6504 0 0 S cameraserver
drm 1776 1 30592 6356 0 0 S drmserver
incidentd 1777 1 12852 3696 0 0 S incidentd
root 1778 1 15460 5004 0 0 S installd
keystore 1779 1 16648 5712 0 0 S keystore
media 1780 1 18408 4560 0 0 S mediadrmserver
mediaex 1781 1 66496 9476 0 0 S media.extractor
media 1782 1 28100 6596 0 0 S media.metrics
media 1783 1 71932 9560 0 0 S mediaserver
root 1784 1 31168 4460 0 0 S netd
statsd 1785 1 15280 3728 0 0 S statsd
root 1786 1 17680 4544 0 0 S storaged
wifi 1787 1 13480 4848 0 0 S wificond
mediacodec 1788 1 39960 6288 0 0 S media.codec
radio 1789 1 17280 4016 0 0 S rild
system 1791 1 13468 3668 0 0 S gatekeeperd
tombstoned 1792 1 6180 2068 0 0 S tombstoned
system 1794 1 10404 3232 0 0 S android.hardware.biometrics.fingerprint@2.1-service
system 1795 1 73348 9524 0 0 S android.hardware.graphics.composer@2.1-service
root 1820 1784 7204 3276 0 0 S iptables-restore
root 1821 1784 7216 3416 0 0 S ip6tables-restore
root 1849 1 6608 552 0 0 S createns
root 1880 1 7212 1828 0 0 S netmgr
root 1907 1 6620 2064 0 0 S dhcpclient
root 1917 1 6876 2068 0 0 S ipv6proxy
wifi 1920 1 9400 3508 0 0 S hostapd_nohidl
root 1922 1 6748 1912 0 0 S dhcpserver
system 1932 1774 1660764 194376 0 0 S system_server
media_rw 2073 1598 0 0 0 0 Z [sdcard]
u0_a26 2088 1774 1512096 132224 0 0 S com.android.systemui
webview_zygote 2105 1774 1335148 38796 0 0 S webview_zygote
wifi 2118 1 15512 2984 0 0 S wpa_supplicant
radio 2186 1774 1456032 93200 0 0 S com.android.phone
u0_a21 2473 1774 1411404 66936 0 0 S com.google.android.ext.services
secure_element 2542 1774 1404016 59380 0 0 S com.android.se
u0_a13 2655 1774 1423300 72612 0 0 S com.google.process.gservices
u0_a61 2674 1774 1401668 58316 0 0 S com.android.smspush
shell 2744 1 17712 1716 0 0 R adbd
mdnsr 2751 1 2612 244 0 0 S mdnsd
u0_a6 3658 1774 1481708 129256 0 0 S com.google.android.apps.nexuslauncher
u0_a31 3794 1774 1443048 86176 0 0 S com.google.android.ims
u0_a85 3908 1774 1448104 78408 0 0 S com.google.android.apps.messaging:rcs
u0_a41 4549 1774 1484684 74116 0 0 S com.google.android.googlequicksearchbox:interactor
u0_a72 6481 1774 1498964 136756 0 0 S com.google.android.inputmethod.latin
u0_a13 6851 1774 1556300 182184 0 0 S com.google.android.gms.persistent
u0_a13 6860 1774 1688152 188808 0 0 S com.google.android.gms
u0_a13 7010 1774 1503160 143964 0 0 S com.google.android.gms.unstable
u0_a41 7073 1774 1561792 181116 0 0 S com.google.android.googlequicksearchbox:search
root 7776 2 0 0 0 0 S [kworker/1:0]
u0_a79 8011 1774 1433232 92044 0 0 S com.google.android.calendar
u0_a39 8025 1774 1406088 77008 0 0 S com.android.providers.calendar
u0_a54 8062 1774 1416044 86508 0 0 S com.google.android.deskclock
u0_a28 8095 1774 1423704 92412 0 0 S com.google.android.setupwizard
root 8232 2 0 0 0 0 S [kworker/1:1]
root 8448 2 0 0 0 0 S [kworker/3:1]
root 8550 2 0 0 0 0 S [kworker/3:0]
root 8601 2 0 0 0 0 S [kworker/2:2]
root 8991 2 0 0 0 0 S [kworker/0:0]
u0_a5 9014 1774 1410536 82400 0 0 S com.google.android.configupdater
u0_a15 9033 1774 1410736 89032 0 0 S android.process.media
root 9193 2 0 0 0 0 S [kworker/u9:2]
root 9235 2 0 0 0 0 S [kworker/u9:4]
root 9481 2 0 0 0 0 S [kworker/2:1]
root 9541 2 0 0 0 0 S [kworker/u8:2]
root 9598 2 0 0 0 0 S [kworker/0:2]
u0_a86 9642 1774 1475096 125504 0 0 S com.mycomp.appfirestore
root 9826 2 0 0 0 0 S [kworker/u8:0]
root 9887 2 0 0 0 0 S [kworker/u8:1]
root 9888 2 0 0 0 0 S [kworker/u9:0]
shell 9922 2744 7632 3004 0 f62fab39 R ps
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>adb shell ls -l /proc/9642/fd
ls: /proc/9642/fd: Permission denied
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>adb shell run-as com.mycomp.appfirestore ls -l /proc/9642/fd
total 0
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 0 -> /dev/null
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 1 -> /dev/null
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 10 -> /system/framework/core-libart.jar
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 11 -> /dev/binder
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 12 -> /system/framework/conscrypt.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 13 -> /system/framework/okhttp.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 14 -> /system/framework/bouncymycomple.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 15 -> /system/framework/apache-xml.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 16 -> /system/framework/ext.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 17 -> /system/framework/framework.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 18 -> /system/framework/telephony-common.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 19 -> /system/framework/voip-common.jar
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 2 -> /dev/null
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 20 -> /system/framework/ims-common.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 21 -> /system/framework/android.hidl.base-V1.0-java.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 22 -> /system/framework/android.hidl.manager-V1.0-java.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 23 -> /system/framework/framework-oahl-backward-compatibility.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 24 -> /system/framework/android.test.base.jar
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 25 -> /system/framework/framework-res.apk
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 26 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 27 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 28 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 29 -> socket:[105880]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 3 -> socket:[105360]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 30 -> socket:[105881]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 31 -> socket:[105883]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 32 -> anon_inode:[eventpoll]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 33 -> socket:[105368]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 34 -> anon_inode:[eventfd]
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 35 -> /data/app/com.mycomp.appfirestore-epBvhJ1O_hVKuIJDOWoZ4Q==/base.apk
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 36 -> socket:[105368]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 37 -> socket:[105368]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 38 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 39 -> socket:[105881]
l-wx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 4 -> /dev/pmsg0
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 40 -> /dev/ashmem
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 41 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 42 -> anon_inode:[eventpoll]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 43 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 44 -> anon_inode:[eventpoll]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 45 -> anon_inode:[eventfd]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 46 -> socket:[105957]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 47 -> socket:[105959]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 48 -> anon_inode:[eventpoll]
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 49 -> /data/app/com.mycomp.appfirestore-epBvhJ1O_hVKuIJDOWoZ4Q==/base.apk
l-wx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 5 -> /sys/kernel/debug/tracing/trace_marker
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 50 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 51 -> socket:[106819]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 52 -> socket:[105961]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 53 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 54 -> /dev/hwbinder
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 55 -> /dev/goldfish_sync
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 56 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 58 -> socket:[107948]
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 6 -> /dev/null
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 61 -> /dev/ashmem
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 04:39 62 -> /dev/ashmem
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 63 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 64 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 65 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 66 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 68 -> /dev/ashmem
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 69 -> /dev/goldfish_pipe
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 7 -> /dev/null
lrwx------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 8 -> /dev/null
lr-x------ 1 u0_a86 u0_a86 64 2020-06-01 05:02 9 -> /system/framework/core-oj.jar
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>netstat -ano | findstr "5038"
TCP 127.0.0.1:5038 0.0.0.0:0 LISTENING 6220
TCP 127.0.0.1:5038 127.0.0.1:57691 ESTABLISHED 6220
TCP 127.0.0.1:5038 127.0.0.1:57733 ESTABLISHED 6220
TCP 127.0.0.1:5038 127.0.0.1:57767 ESTABLISHED 6220
TCP 127.0.0.1:5038 127.0.0.1:57769 ESTABLISHED 6220
TCP 127.0.0.1:57691 127.0.0.1:5038 ESTABLISHED 12920
TCP 127.0.0.1:57733 127.0.0.1:5038 ESTABLISHED 12920
TCP 127.0.0.1:57767 127.0.0.1:5038 ESTABLISHED 12920
TCP 127.0.0.1:57769 127.0.0.1:5038 ESTABLISHED 12920
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>netstat -ano | findstr "5037"
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 4944
TCP 127.0.0.1:60754 127.0.0.1:5037 TIME_WAIT 0
... a lot lines delted with same TIME_WAIT for port 5037 TCP 127.0.0.1:60909 127.0.0.1:5037 TIME_WAIT 0 TCP 127.0.0.1:60911 127.0.0.1:5037 TIME_WAIT 0 TCP 127.0.0.1:60916 127.0.0.1:5037 TIME_WAIT 0
C:\Users\mycomp\AppData\Local\Android\Sdk\platform-tools>
PS.: in case you wonder why I have port 5038 it is because I created an Environment variable named ANDROID_ADB_SERVER_PORT with 5038
PS2.: I believe I added all relevant info above but if someone wish to see the whole project here is repository. It is really a small project with only a simple layout and the above Kotlin code.