The optional param maxSize of the GetData() function was missing in "snc.bi".
Download SimpleNetworkConnection.zip again
If you receive any unknow size of data Data
you can fill a buffer while you get any data and interrupt if a timeout happens.
This timeout was the problem every call to GetData() was waiting this timeout delay.
If you receive data and knows it's size
you can fill a buffer while received bytes < dataSize or a timeout happens.
note: Transfering a large block of data in chunks of 8 KB is much faster as a chunk size of for example 256 KB.
You can compare the time if you change DATA_PAKET_SIZE from 1024*8 to 1024*256.
Code: Select all
#include once "snc.bi"
const PORT = 12345
const DATA_PAKET_SIZE = 1024*8 ' 8 KB
dim as ubyte ptr pData,pDatapacket = allocate(DATA_PAKET_SIZE)
var t = timer()
var Server = new NetworkServer(PORT)
print "time to create a local server: " & t
var Client = new NetworkClient("127.0.0.1",PORT)
print "time to create a local client: " & t
var ToClient = Server->getConnection()
print "time to get client connection: " & t
var ToServer = Client->getConnection()
print "time to get server connection: " & t
print "mensured data tranfer rate"
dim as double tPut,tGet
dim as integer processed,nbytes
while processed < 1024*1024 ' 1 MB
nBytes = ToServer->PutData(pDatapacket,DATA_PAKET_SIZE)
print "time to put: " & tPut
print "time to get: " & tGet
print "time to send and receive 1 MB in packages of 8 KB : " & t
print "done ..."