Last active
November 6, 2019 00:58
-
-
Save ba0f3/cb654ca7fd376b79d59676ff834a908c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = file.readFile() | |
var filedata = splitToChunks(data,24) | |
echo filedata | |
for i in filedata: | |
echo i | |
client.send(i & "\r\L") | |
client.send("DONE" & "\r\L") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = file.readFile() | |
var filedata = splitToChunks(data,24) | |
echo filedata | |
for i in filedata: | |
echo i | |
client.send(i & "\r\L") | |
client.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = "" | |
var output = open("D:\\test.txt",fmWrite) | |
while data != "DONE": | |
echo "Receving..." | |
output.write(data & "\r\L") | |
data = client.recvLine() | |
echo "DONE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MAX_BUFFER_SIZE = 1024 | |
var buffer: array[MAX_BUFFER_SIZE, char] # pre-allcated buffer | |
var output = open("D:\\test.txt",fmWrite) | |
var readLength = server.recv(addr buffer, MAX_BUFFER_SIZE) # server try to read 104 bytes from client, but if client send less, it will return in readLength | |
while readLength != -1: # if there is no data, or client disconnected, readLength will returns -1 | |
echo "Receving..." | |
output.writeBuffer(addr buffer, readLength) # write everything it read from client to output file | |
readLength = server.recv(addr buffer, MAX_BUFFER_SIZE) # continue receiving | |
server.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment