Android Question Is it possible to disable the TCP Nagle algorithm?

wbtcpip

Member
Licensed User
Longtime User
when using the socket of B4X on Android is there an option to disable the TCP Nagle algorithm? sometimes called TCP_NODELAY option
 

drgottjr

Expert
Licensed User
Longtime User
you can try this:
B4X:
    Dim sock As Socket
    sock.Initialize("sock")

    Dim sockjo As JavaObject
    sockjo = sock    ' is a wrapper, not a socket
    ' get wrapper's socket
    Dim actualsocket As JavaObject

    actualsocket = sockjo.GetField("socket")
    Dim isOn As Boolean = actualsocket.RunMethod("getTcpNoDelay",Null)
    Log("is nagle on ? " & isOn)
    
    If isOn Then
        Log("will turn nagle off")
        actualsocket.RunMethod("setTcpNoDelay",Array( False ))
    Else
        Log("will turn nagle on")
        actualsocket.RunMethod("setTcpNoDelay",Array( True ))
    End If

    Log("is nagle on? " & actualsocket.RunMethod("getTcpNoDelay",Null))

it seemed to do something...
 

Attachments

  • nagle.png
    nagle.png
    29.1 KB · Views: 50
  • Like
Reactions: RJB
Upvote 1
Top