This winsock code runs for 2 or 3 times and after that i keep getting same error line: MSG.text = "Error 10035: sock not ready or nothing was sent to server". Could not find exact reason, look like multiple request handling is the problem because this morning after booting up system it worked and 2 records were received from client side. Not sure what to do. I am using this script in pbm_custom02. Please take a look.
string ls_request
int li_clientlen
String TheData
// Accept client requests
clientsock = u_test.uf_accept(sock, TheAddress)
// Get the data sent by client
TheData = String(u_test.uf_getrequestdata(clientsock)) /// -1 when null received
IF Trim(String(RecentError)) = "10035" THEN
MSG.text = "Error 10035: sock not ready or nothing was sent to server"
u_test.uf_closesocket(clientsock)
Return
END IF
IF Trim(TheData) = "-1" THEN
MSG.text = "Error -1: something went wrong with server"
u_test.uf_closesocket(clientsock)
Return
END IF
/// decrypt the data
n_bcrypt Blender
String EncType = "AES", MyPas = "MySecretKey", MyVect = "MyPublicCryptKey"
PlainData = Blender.of_decrypthex(EncType, TheData, MyPas, MyVect )
IF IsNull(PlainData ) Then
MSG.Text = "Blender Error: of_decrypt failed. "
u_test.uf_closesocket(clientsock)
Return
End If
/// extract and add row
Event _Extract(TheData)
IF Trim(ErrorBuffer) <> "" THEN
MSG.Text = ErrorBuffer
ELSE
MSG.Text = "This is What I got: " + String(RecentError) + " DATA: " + String( TheData)
END IF
//Send some data back
u_test.uf_senddata(clientsock, Blob("<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY><H1>I hear ya</H1></BODY></HTML>"))
//Close client socket
u_test.uf_closesocket(clientsock)
most welcome.
Added the sleep(.5) just before the uf_accept() function.
Sleep(.5)
/// Accept client requests
clientsock = u_test.uf_accept(sock, TheAddress)