SkythekidRS

Hello, help me this error (TCP send picture )

18 posts in this topic

#1 ·  Posted (edited)

:( i'm try a lot of way but the image from another computer ( i use TCP to send picture ) always like this....
4DVhTrr.jpg

please help me....it's just load a little of image

Edited by SkythekidRS

Share this post


Link to post
Share on other sites



Can you show us the full code used to send the picture? We can't help you without any code

 

TD :)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

I am looking at it now...


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Try this:

server.au3:

TCPStartup()
$ip='192.168.1.4'
$listen=TCPListen($ip,4444)

Do
    $socket=TCPAccept($listen)
    $data=TCPRecv($socket,1342177280)

Until $data<>Null
$op=FileOpen('khang.jpg',18)
FileWrite($op,$data)

client.au3

TCPStartup()
$ip='192.168.1.4'

$op=FileOpen('IMG_2474.JPG',16)
$connect=TCPConnect($ip,4444)
TCPSend($connect,FileRead($op))
TCPSend($connect,Null)
FileClose($op)

 

TD :)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Thanks for help me :D i will test that script

Share this post


Link to post
Share on other sites

something wrong with the server script, i run then it close. 

Share this post


Link to post
Share on other sites

@SkythekidRS Hmmm... try replacing Null with "Complete"


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

now it create an image and exit before i run the client script @@! 

Share this post


Link to post
Share on other sites

Crap, Replace <> with =

 

I forgot to change those, TD :sweating:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
TCPStartup()
$ip=@IPAddress1
$listen=TCPListen($ip,4444)

Do
    $socket=TCPAccept($listen)
    $data=TCPRecv($socket,1342177280)

Until $data="Complete"
$op=FileOpen('khang.jpg',18)
FileWrite($op,$data)
FileClose($op)


 

TCPStartup()
$ip=@IPAddress1

$op=FileOpen('IMG.jpg',16)
$connect=TCPConnect($ip,4444)
TCPSend($connect,FileRead($op))
TCPSend($connect,"Complete")
FileClose($op)

is this right?.....not work :<

Share this post


Link to post
Share on other sites

@SkythekidRS I am experimenting with TCP now, I will post a solution once I figure out the problem :)

1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

Ahhh.... I am still experimenting but I ran out of time :(, I need to go to bed. I will try to solve this issue tomorrow

 

TD :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

you can send big file ;)

server

TCPStartup()

Global $ip = @IPAddress1
Global $Port = 4444
Global $sSocket = -1

Global $LenSendData = 1024 * 1024 
Global $PackSendfile = "[PackSendfile]"
Global $EndPackSendfile = "[EndPackSendfile]"
Global $lenEndPackSendfile = StringLen($EndPackSendfile)
Global $RecevFileok = "[RecevFileok]"
Global $Spdata = "[#Spdata]"

Global $listen = TCPListen($ip, $Port)
Global $sSocket = _Tcp_Get_Connection($listen)

While True
    Sleep(100)
    _Getcmdtype($sSocket)
WEnd

Func _Getcmdtype($tsSocket)
    Local $Getcmdtype = TCPRecv($tsSocket, 999)
    If $Getcmdtype = "" Then Return False
    Select
        Case StringInStr($Getcmdtype, $PackSendfile) > 0
            Local $Getfileinfo = StringSplit($Getcmdtype, $Spdata, 1)
            If @error Then Return False
            Local $Filesize = $Getfileinfo[2]
            Local $cSavepath = FileSaveDialog("Choose a filename...", @WorkingDir, "All (*.*)", 18, "test")
            If @error Then Return _Tcp_Exit()
            MsgBox(0, "", _Getdisplaysize(_Tcp_Rcv_File($tsSocket, $Filesize, FileGetShortName($cSavepath))) & " it was rcv")
            _Tcp_Exit()
    EndSelect
EndFunc   ;==>_Getcmdtype

Func _Tcp_Rcv_File($sSocket, $Filesize, $cSavepath)
    Local $op, $Binfile, $binlen, $Timer, $tbinlen, $ps
    TCPSend($sSocket, $RecevFileok)
    $op = FileOpen($cSavepath, 18)
    ProgressOn("Progress Meter", "Receive state", "Start",default,default,16)
    $Timer = TimerInit()
    Do
        $Binfile = ""
        Do
            $Binfile &= TCPRecv($sSocket, $LenSendData)
        Until StringRight($Binfile, $lenEndPackSendfile) = $EndPackSendfile
        $Binfile = StringSplit($Binfile, $EndPackSendfile, 1)
        $Binfile = $Binfile[1]
        $binlen += BinaryLen($Binfile)
        FileWrite($op, $Binfile)
        TCPSend($sSocket, $RecevFileok)
        
        If TimerDiff($Timer) >= 1000 Then
            $Rate = $binlen - $tbinlen
            $ps = ($binlen / $Filesize) * 100
            $tbinlen = $binlen
            ProgressSet(Int($ps), "Receive " & _Getdisplaysize($binlen) & " Of " & _Getdisplaysize($Filesize) & " " & Int($ps) & " % Rate " & _Getdisplaysize($Rate))
            $Timer = TimerInit()
        EndIf
        
    Until $Filesize = $binlen
    ProgressOff()
    FileClose($op)
    Return $binlen
EndFunc   ;==>_Tcp_Rcv_File

Func _Tcp_Get_Connection($sSocketlisten)
    Local $stSocket
    Do
        $stSocket = TCPAccept($listen)
    Until $stSocket <> -1
    Return $stSocket
EndFunc   ;==>_Tcp_Get_Connection

Func _Tcp_Exit()
    TCPCloseSocket($listen)
    TCPCloseSocket($sSocket)
    TCPShutdown()
    Exit
EndFunc   ;==>_Tcp_Exit

Func _Getdisplaysize($isize)
    If $isize < 1 Then Return 0
    Local $abytes[5] = [' Bytes', ' Kb', ' Mb', ' Go', ' Tb']
    For $i = 4 To 1 Step -1
        If $isize >= 1024 ^ $i Then Return Round($isize / 1024 ^ $i, 1) & $abytes[$i]
    Next
    Return $isize & $abytes[0]
EndFunc   ;==>_Getdisplaysize

 

client

TCPStartup()

Global $ip = @IPAddress1
Global $Port = 4444

Global $LenSendData = 1024 * 1024 
Global $PackSendfile = "[PackSendfile]"
Global $EndPackSendfile = "[EndPackSendfile]"
Global $RecevFileok = "[RecevFileok]"
Global $Spdata = "[#Spdata]"

Global $Connect = _Tcp_Clien_Connect($ip, $Port)

Global $mFilepath = FileOpenDialog("Select a file..", @WorkingDir & "\", "All (*.*)", 1)
If Not @error Then MsgBox(0, "", _Getdisplaysize(_Tcp_Send_file($Connect, FileGetShortName($mFilepath))) & " it was sent")

TCPCloseSocket($Connect)
TCPShutdown()

Func _Tcp_Send_file($stSocket, $mFilepath)
    Local $op, $Iread, $rcv, $binlen, $Filesize, $Timer, $tbinlen, $ps, $zError = False
    $Filesize = FileGetSize($mFilepath)
    TCPSend($stSocket, $PackSendfile & $Spdata & $Filesize)
    Do
        $rcv &= TCPRecv($stSocket, 24)
    Until $rcv = $RecevFileok
    $op = FileOpen($mFilepath, 16)
    ProgressOn("Progress Meter", "Send state", "Start",default,default,16)
    $Timer = TimerInit()
    While True
        $Iread = FileRead($op, $LenSendData)
        If @error Then ExitLoop
        TCPSend($stSocket, $Iread & $EndPackSendfile)
        $binlen += BinaryLen($Iread)
        $rcv = ""
        Do
            $rcv &= TCPRecv($stSocket, 24)
        Until $rcv = $RecevFileok
        
        If TimerDiff($Timer) >= 1000 Then
            $Rate = $binlen - $tbinlen
            $ps = ($binlen / $Filesize) * 100
            $tbinlen = $binlen
            ProgressSet(Int($ps), "Sent " & _Getdisplaysize($binlen) & " Of " & _Getdisplaysize($Filesize) & " " & Int($ps) & " % Rate " & _Getdisplaysize($Rate))
            $Timer = TimerInit()
        EndIf
        
    WEnd
    ProgressOff()
    FileClose($op)
    Return $binlen
EndFunc   ;==>_Tcp_Send_file

Func _Tcp_Clien_Connect($sIp, $mPort)
    Local $sSocket
    Do
        Sleep(100)
        $sSocket = TCPConnect($sIp, $mPort)
    Until $sSocket <> -1
    Return $sSocket
EndFunc   ;==>_Tcp_Clien_Connect

Func _Getdisplaysize($isize)
    If $isize < 1 Then Return 0
    Local $abytes[5] = [' Bytes', ' Kb', ' Mb', ' Go', ' Tb']
    For $i = 4 To 1 Step -1
        If $isize >= 1024 ^ $i Then Return Round($isize / 1024 ^ $i, 1) & $abytes[$i]
    Next
    Return $isize & $abytes[0]
EndFunc   ;==>_Getdisplaysize

 

1 person likes this

Share this post


Link to post
Share on other sites

please :D can you make it simple? i try to understand that but so hard..

Share this post


Link to post
Share on other sites

ok,

try this

TCPStartup()
$ip = @IPAddress1
$listen = TCPListen($ip, 4444)

Local $data, $socket = -1

Do
    If $socket = -1 Then
        $socket = TCPAccept($listen)
    EndIf
    If $socket <> -1 Then
        $data &= TCPRecv($socket, 1024 * 1024)
    EndIf
Until StringRight($data, 8) = "Complete"

TCPSend($socket, "Complete")

$data = StringTrimRight($data, 8)

$op = FileOpen('khang.jpg', 18)
FileWrite($op, $data)
FileClose($op)

client

TCPStartup()
$ip = @IPAddress1

Do
    $connect = TCPConnect($ip, 4444)
Until $connect <> -1

$op = FileOpen('IMG.jpg', 16)
TCPSend($connect, FileRead($op) & "Complete")
FileClose($op)

Do
    Sleep(1)
Until TCPRecv($connect, 8) = "Complete"

 

1 person likes this

Share this post


Link to post
Share on other sites

If you need to ONLY transfert ONE file, all you have to do when transfert is done is to close the connection. No need for completion markers.

If you need to transfert multiple files, end marker isn't the best solution. You'll have to announce file size first, then transfert file.

1 person likes this

Share this post


Link to post
Share on other sites

I know that :D thanks for reply me guys. And thanks for the help.

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