Send/ReceiveNetworkData() and delays
Posted: Mon Jun 23, 2003 3:17 am
Hello all. Just examining PB to see if I might be able to write a windows server in it.. Looks all good but my initial experiments left me a little confused about some things.
This is what i'm using in my server 's WaitWindowEvent() loop
And this is in the client..
What happens is that from the time the server sends it's little "Hello" message there is a 1- 5 second delay before I see it on the client side. I verified this with telnet so I'm pretty sure it's not anything I'm doing wrong in the client.. Is it some sort of windows buffering? Is there a way to flush those buffers so that data gets sent ASAP?
And one last thing.. In some network examples and older forum posts I'm seeing this but I'm not really sure what it gets me. If someone could explain the advantage this gives I'd appreciate it!
Thanks!!
This is what i'm using in my server 's WaitWindowEvent() loop
Code: Select all
Select NetworkServerEvent()
Case 1
AddGadgetItem(#Gadget_wnd_windowmain_ed_messages,-1,"User connection detected")
; User connected, display hello message.
s_message.s = "Hello, welcome to the PB server! Yay!"
SendNetworkData(NetworkClientID(), @s_message, Len(s_message)+1)
Case 2
AddGadgetItem(#Gadget_wnd_windowmain_ed_messages,-1,"New data detected")
; New data. Add it to our editor gadget.
s_received_buffer.s = Space(512)
ReceiveNetworkData(NetworkClientID(), @s_received_buffer, Len(s_received_buffer)+1)
AddGadgetItem(#Gadget_wnd_windowmain_ed_messages,-1,s_received_buffer)
EndSelect
Code: Select all
Select NetworkClientEvent(l_conn_id)
Case 2
; New data. Add it to our editor gadget.
s_received_buffer.s = Space(512)
ReceiveNetworkData(l_conn_id, @s_received_buffer, Len(s_received_buffer)+1)
AddGadgetItem(#Gadget_wnd_windowmain_ed_messages,-1,s_received_buffer)
EndSelect
And one last thing.. In some network examples and older forum posts I'm seeing this but I'm not really sure what it gets me. If someone could explain the advantage this gives I'd appreciate it!
Code: Select all
#FD_ALL = #FD_READ|#FD_WRITE|#FD_OOB|#FD_ACCEPT|#FD_CONNECT|#FD_CLOSE
WSAAsyncSelect_(l_conn_id, WindowID(), #WM_NULL, #FD_ALL)