10 seconds wifi network slowdown latency with SendData win 11

Find quick help here to get you started with Hollywood
Post Reply
P_B
Posts: 27
Joined: Sat Sep 15, 2018 4:28 pm

10 seconds wifi network slowdown latency with SendData win 11

Post by P_B »

Hello,

On Windows 11, I am never connected via wifi to the internet, but via wire.

I wanted to test the wifi connection, but only locally, without any internet connection.

I have wifi enabled, as well as a wireless mobile hotspot.

https://youtu.be/rQq87isfLHo

Here is a server program and another client, which will need to be compiled separately and to authorize firewall.

For the client program, you will need to enter the correct IP.

At home I get:

Connection to local network* 2 192.168.137.1 1

That is : 192.168.137.1 for OpenConnection in client

Launch the server program.
Launch the client program.

***WAITLEFTMOUSE***

Click on the client window to start the connection.

The server detects the connection very quickly.

The client sends the "OPENCONNECTION FROM CLIENT" message to the server

The client displays:

"(ONCONNECT FROM SERVER)" 8 seconds later :shock:
"(ACK FROM SERVER)" 11 seconds later :shock:

When I click on the red square the client sends the "XOR" message,
the server will display it 10 seconds later. :shock:

When I click on the blue square the server sends the "CLICK" message,
the client will display it 10 seconds later. :shock:

Even if I deactivate the firewall, I get the same results.

Do you have the same results as me, with such modern equipment :?:

Code: Select all

@DISPLAY {title="Server"}

SetFont(#SANS, 16)
SetFontStyle(#ANTIALIAS)

Function p_MyFunc(msg)

  Switch msg.action

  Case "OnMouseUp":

    SendData(cliid,"CLIC")

  EndSwitch

EndFunction

Box(200, 200, 100, 100, #BLUE)

evtmatch = {OnMouseUp = p_MyFunc}
						
MakeButton(1,#SIMPLEBUTTON, 200, 200, 100, 100, evtmatch)

NPrint("+1+")

t = GetLocalInterfaces()

For Local k = 0 To ListItems(t) - 1
 
  NPrint(t[k].Name, t[k].Address, t[k].Protocol)
  DebugPrint(t[k].Name, t[k].Address, t[k].Protocol)

Next

NPrint("+1+")

CreateServer(1,2550)

NPrint(GetLocalPort(1,#NETWORKSERVER))

NPrint("+2+")

Function p_ConnectFunc(msg)
	
  Switch(msg.action)
		
  Case "OnConnect":
		
    NPrint("Connected client id : ", GetLocalIP(msg.clientid))
    NPrint("id : ",msg.clientid)
	  
    SendData(msg.clientid,"(ONCONNECT FROM SERVER)")
		
    cliid=msg.clientid
		
    NPrint(cliid)
				
  Case "OnReceiveData":
		
    data$ = ReceiveData(cliid, #RECEIVELINE)

    NPrint(cliid,data$,msg.id)
		
    SendData(msg.id,"(ACK FROM SERVER)")
		
  EndSwitch

EndFunction

InstallEventHandler({OnConnect = p_ConnectFunc, onreceivedata=p_connectfunc})

Repeat
	
  CheckEvent
	
  Wait(1)

Forever

Code: Select all

@DISPLAY {title="Client"}

SetFont(#SANS, 24)
SetFontStyle(#ANTIALIAS)

Function p_MyFunc(msg)
	
  Switch msg.action
		
  Case "OnMouseUp":
	  
    SendData(1, "XOR")
	  
  EndSwitch
  
EndFunction

Box(200, 200, 100, 100, #RED)

evtmatch = {OnMouseUp = p_MyFunc}

MakeButton(1, #SIMPLEBUTTON, 200, 200, 100, 100, evtmatch)

NPrint("+1+")

t = GetLocalInterfaces()

For Local k = 0 To ListItems(t) - 1

  NPrint(t[k].Name, t[k].Address, t[k].Protocol)
  DebugPrint(t[k].Name, t[k].Address, t[k].Protocol)

Next

NPrint("+1+")

CreateServer(1,2550)

NPrint(GetLocalPort(1,#NETWORKSERVER))

NPrint("+2+")

NPrint("*** WAITLEFTMOUSE ***")

WaitLeftMouse

OpenConnection(1,"192.168.137.1", 2550)

NPrint("+OPENCONNECTION+")

SendData(1,"OPENCONNECTION FROM CLIENT")

Function p_ConnectFunc(msg)
		
  Switch(msg.action)
		
  Case "OnReceiveData":	
		
    data$ = ReceiveData(msg.id, #RECEIVELINE)
		
    NPrint(data$)
		
  EndSwitch

EndFunction

InstallEventHandler({OnReceiveData = p_ConnectFunc})

Repeat
	
  CheckEvent
	
  ;Wait(1)

Forever

CloseConnection(1)
P_B
Posts: 27
Joined: Sat Sep 15, 2018 4:28 pm

Re: 10 seconds wifi network slowdown latency with SendData win 11

Post by P_B »

Sorry, in the client program, I forgot to delete the CreateServer lines, delete them for the tests
In programme client. :oops:

Code: Select all

NPrint("+1+")

CreateServer(1,2550)

NPrint(GetLocalPort(1,#NETWORKSERVER))

Code: Select all

@DISPLAY {title="Client"}

SetFont(#SANS, 24)
SetFontStyle(#ANTIALIAS)

Function p_MyFunc(msg)
	
  Switch msg.action
		
  Case "OnMouseUp":
	  
    SendData(1, "XOR")
	  
  EndSwitch
  
EndFunction

Box(200, 200, 100, 100, #RED)

evtmatch = {OnMouseUp = p_MyFunc}

MakeButton(1, #SIMPLEBUTTON, 200, 200, 100, 100, evtmatch)

NPrint("+1+")

t = GetLocalInterfaces()

For Local k = 0 To ListItems(t) - 1

  NPrint(t[k].Name, t[k].Address, t[k].Protocol)
  DebugPrint(t[k].Name, t[k].Address, t[k].Protocol)

Next

NPrint("+2+")

NPrint("*** WAITLEFTMOUSE ***")

WaitLeftMouse

OpenConnection(1,"192.168.137.1", 2550)

NPrint("+OPENCONNECTION+")

SendData(1,"OPENCONNECTION FROM CLIENT")

Function p_ConnectFunc(msg)
		
  Switch(msg.action)
		
  Case "OnReceiveData":	
		
    data$ = ReceiveData(msg.id, #RECEIVELINE)
		
    NPrint(data$)
		
  EndSwitch

EndFunction

InstallEventHandler({OnReceiveData = p_ConnectFunc})

Repeat
	
  CheckEvent
	
  ;Wait(1)

Forever

CloseConnection(1)
Thanks you.
Flinx
Posts: 226
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: 10 seconds wifi network slowdown latency with SendData win 11

Post by Flinx »

You call ReceiveData() to read one line (#RECEIVELINE), but your strings does not contain any line feed. So ReceiveData() waits until the internal timeout.
Write a "\n" at the end of the strings to send, then it works.
And I would not use CheckEvent in the main loop. The polling eats CPU cycles, and the Wait() causes an unnecessary delay. Use WaitEvent() instead.
P_B
Posts: 27
Joined: Sat Sep 15, 2018 4:28 pm

[Solved]10 seconds wifi network slowdown latency with SendData win 11

Post by P_B »

Thank you Flinx for your help.

Now everything works perfectly and at the right speed.

Without your expert advice 8-) , I would not have found the real cause of the problem.

Thanks again for everything.

Code: Select all

@DISPLAY {title="Server"}

SetFont(#SANS, 16)
SetFontStyle(#ANTIALIAS)

Function p_MyFunc(msg)

  Switch msg.action

  Case "OnMouseUp":

    SendData(cliid,"CLIC\n")

  EndSwitch

EndFunction

Box(200, 200, 100, 100, #BLUE)

evtmatch = {OnMouseUp = p_MyFunc}
						
MakeButton(1,#SIMPLEBUTTON, 200, 200, 100, 100, evtmatch)

NPrint("+1+")

t = GetLocalInterfaces()

For Local k = 0 To ListItems(t) - 1

  NPrint(t[k].Name, t[k].Address, t[k].Protocol)

  DebugPrint(t[k].Name, t[k].Address, t[k].Protocol)

Next

NPrint("+1+")

CreateServer(1,2550)

NPrint(GetLocalPort(1,#NETWORKSERVER))

NPrint("+2+")

Function p_ConnectFunc(msg)
	
  Switch(msg.action)
		
  Case "OnConnect":
		
    NPrint("Connected client id : ", GetLocalIP(msg.clientid))
    NPrint("id : ",msg.clientid)
		
    SendData(msg.clientid,"(ONCONNECT FROM SERVER)\n")
		
    cliid=msg.clientid
		
    NPrint(cliid)
				
  Case "OnReceiveData":
		
    data$ = ReceiveData(cliid, #RECEIVELINE)

    NPrint(cliid,data$,msg.id)
		
    SendData(msg.id,"(ACK FROM SERVER)\n")
		
  EndSwitch

EndFunction

InstallEventHandler({OnConnect = p_ConnectFunc, onreceivedata=p_connectfunc})

Repeat
	
  WaitEvent()
	
Forever

Code: Select all

@DISPLAY {title="Client"}

SetFont(#SANS, 24)
SetFontStyle(#ANTIALIAS)

Function p_MyFunc(msg)
	
  Switch msg.action
		
    Case "OnMouseUp":
		
    SendData(1, "XOR\n"	)
		
  EndSwitch
	
EndFunction

Box(200, 200, 100, 100, #RED)

evtmatch = {OnMouseUp = p_MyFunc}

MakeButton(1, #SIMPLEBUTTON, 200, 200, 100, 100, evtmatch)

NPrint("+1+")

t = GetLocalInterfaces()

For Local k = 0 To ListItems(t) - 1
  NPrint(t[k].Name, t[k].Address, t[k].Protocol)
  DebugPrint(t[k].Name, t[k].Address, t[k].Protocol)
Next

NPrint("+2+")

NPrint("*** WAITLEFTMOUSE ***")

WaitLeftMouse

OpenConnection(1,"192.168.137.1", 2550)

NPrint("+OPENCONNECTION+")

SendData(1,"OPENCONNECTION FROM CLIENT\n")

Function p_ConnectFunc(msg)
		
  Switch(msg.action)
		
  Case "OnReceiveData":	
		
    data$ = ReceiveData(msg.id, #RECEIVELINE)
		
    NPrint(data$)
		
  EndSwitch

EndFunction

InstallEventHandler({OnReceiveData = p_ConnectFunc})

Repeat
	
  WaitEvent()
	
Forever

CloseConnection(1)
Post Reply