Sign in to follow this  
Followers 0
Cyber

TCP Binary file transfert

7 posts in this topic

Hi all!

I found many function for TCP file trasfert, but its hard to work with big file >_<

Do you have a function with example?

Thanks!


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites



Read & send the file in smaller chunks (for example 32 kB).


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Read & send the file in smaller chunks (for example 32 kB).

how?


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

FileRead has a count parameter, so this for exampe reads 32 kB of data.

$fhandle=FileOpen("test.file",16)
$data=FileRead($fhandle,32*1024)

Then you just have to send that data and redo the process until no more data could be fetched from the file (end of file).

On the reciever side you just dump everything that comes through the socket into a file.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

FileRead has a count parameter, so this for exampe reads 32 kB of data.

$fhandle=FileOpen("test.file",16)
$data=FileRead($fhandle,32*1024)

Then you just have to send that data and redo the process until no more data could be fetched from the file (end of file).

On the reciever side you just dump everything that comes through the socket into a file.

Thanks

I try but my code don't work.

Can you help me please? >_<

Opt("TrayIconDebug", 1)
TCPStartup()

$sock = -1
Do
    $sock =TCPConnect(@IPAddress1,3333)
Until $sock <> -1

$fhandle=FileOpen("file.rar",16)

$r = ""
$i = 0
Do
    $r = TCPRecv($sock, 1000000)
    if @error <> 0 Then
        ExitLoop
    EndIf
    if $r <> "" Then
        $i += 1
        TrayTip("",$i,1)
        FileWrite($fhandle, $r)
    EndIf
    
Until @error <> 0

FileClose($fhandle)
TCPCloseSocket($sock)

TCPShutdown()

Opt("TrayIconDebug", 1)

TCPStartup()

$mainsock = TCPListen(@IPAddress1, 3333)

$sock = -1

Do
    $sock = TCPAccept($mainsock)
Until $sock <> -1


$fhandle=FileOpen("test.file",16)

$i = 0
While 1
    $i += 1
;~  TrayTip("",$i,1)
    Sleep(10)
    $data=FileRead($fhandle,32*1024)
    If @error = -1 Then ExitLoop
    
    TCPSend($sock, $data)
Wend    
FileClose($fhandle)

TCPCloseSocket($sock)

TCPShutdown()
Edited by Cyber

Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

Share this post


Link to post
Share on other sites

You need to open the output file in write mode, so replace "FileOpen("file.rar")" with "FileOpen("file.rar",17)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

You need to open the output file in write mode, so replace "FileOpen("file.rar")" with "FileOpen("file.rar",17)

WORK!!!!!

FANTASTIC!!!!!!!!!

THANKS!!! >_<

THANKS THANKS THANKS THANKS THANKS THANKS!!! :(


Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

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