Sign in to follow this  
Followers 0
Noobster24

See how many bytes recieved

3 posts in this topic

Hi,

i found this script once on the forum:

Dim $iMainSocket = -1, $iSocket = -1
Dim $buffer = ""
Dim $bytes = -1
Dim $iRet = -1

TCPStartup()

$iMainSocket = TCPListen(@IPAddress1,50911)

While 1
    If $iSocket = -1 Then
        $iRet = TCPAccept($iMainSocket)
        If Not @error Then $iSocket = $iRet
    Else
        $buffer &= TCPRecv($iSocket,4096)
        If $bytes = -1 And StringInStr($buffer,",") Then
            $bytes = StringLeft($buffer,StringInStr($buffer,",")-1)
            $buffer = StringTrimLeft($buffer,StringInStr($buffer,","))
        Else
            SplashTextOn("Receive","Receiving ...",200,40)          
            If StringLen($buffer) = $bytes Then
                SplashOff()
                $FileReceived = FileSaveDialog("File save",@desktopdir,"All (*.*)")
                ExitLoop
            EndIf
        EndIf
    EndIf
WEnd

FileDelete($FileReceived)
FileWrite($FileReceived,$buffer)

MsgBox(4096,"","Transfer Complete")

TCPShutdown()
This is the reciever.au3 (I don't know how made it, but thanks for it)

How can i see how many bytes are recieved?


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites



Just use StringLen() on the received data, as used in the script : StringLen($buffer)

I remember when I started to played with this kind of stuff I got a script which did basically

does the same as yours, however I did find out that StringLen() slows the script down as

the received data gets bigger and bigger. To solve that just do something like this :

$recv = TCPRecv()
$recv_bytes = StringLen($recv)

$data &= $recv
$data_bytes += $recv_bytes

If $data_bytes = $target_bytes Then ; finished

Share this post


Link to post
Share on other sites

Just use StringLen() on the received data, as used in the script : StringLen($buffer)

I remember when I started to played with this kind of stuff I got a script which did basically

does the same as yours, however I did find out that StringLen() slows the script down as

the received data gets bigger and bigger. To solve that just do something like this :

$recv = TCPRecv()
$recv_bytes = StringLen($recv)

$data &= $recv
$data_bytes += $recv_bytes

If $data_bytes = $target_bytes Then ; finished

Ah thanks man! You rock :)


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0