Test powershell code
Function QM_TcpSocket_server
cls
$filePath = "$home\desktop\Test\Doc.docx"
$fileBytes = [System.IO.File]::ReadAllBytes($filePath)
$fileBase64 = [Convert]::ToBase64String($fileBytes)
$formData = @{
"fileName" = "Doc.docx"
"fileBase64" = $fileBase64
}
Invoke-RestMethod -Uri "http://127.0.0.1:5032/saveFile" -Method Post -Body $formData -ContentType 'multipart/form-data'
Function QM_TcpSocket_server
if(getopt(nthreads)>1) ret
AddTrayIcon "cut.ico" "test_TcpSocket_server[]Ctrl+click to end."
#compile "__TcpSocket"
TcpSocket x.ServerStart(5032 &sub.OnClientConnected)
#sub OnClientConnected
function TcpSocket&client $clientIp param !*reserved
;Test file(Pic.png) size is 1342KB; file(Doc.docx) size is 525KB
;The response speed is very fast, but The data reception is unstable, sometimes complete and sometimes incomplete.
client.Receive(_s 2048000)
;The response speed is too slow, but The received data is always complete, the response speed is still very slow even when testing locally.
;client.Receive(_s 0)
out F"SERVER: client request:[]{_s}"
str r="File saved"
client.Send(F"HTTP/1.1 200 OK[]Content-Type: text/plain[]Content-Length: {r.len}[][]{r}")