Sign in to follow this  
Followers 0
torels

tcp problem

4 posts in this topic

hi there

I'm working on a program that sends commands through tcp from a computer to another... but the client isn't working...

here is my code:

Server

#include <GUIConstantsEx.au3>
Global $ConnectedSocket

$Gui = GUICreate("InterAct (Server) - torels_", 624, 451, 193, 125)
$edit = GUICtrlCreateEdit("", 8, 48, 609, 375)
$cIP = GUICtrlCreateCombo("<local>", 8, 16, 169, 25)
GUICtrlSetData(-1, "<local>")
$connect = GUICtrlCreateButton("Connect",180,15,100,23)
$filemnu = GUICtrlCreateMenu("File")
$SaveToFile = GUICtrlCreateMenuItem("Save Output to file...",$filemnu)
$Exit = GUICtrlCreateMenuItem("Exit",$filemnu)
$infomnu = GUICtrlCreateMenu("Info")
$torels = GUICtrlCreateMenuItem("torels_", $infomnu)
GUISetState(@SW_SHOW)

While 1
        Switch GUIGetMsg()
            case -3
                Exit
            Case $connect
                $ip = GUICtrlRead($cIP)
                if $ip = "<local>" then $ip = @IPAddress1
                _Connect($ip)
            Case $Exit
                TCPShutdown()
                Exit
            Case $SaveToFile
                _saveOutputToFile(Guictrlread($edit))
        EndSwitch
        
        $recv = TCPRecv($ConnectedSocket, 1024 * 1024)

        If $recv <> "" Then GUICtrlSetData($edit,GUICtrlRead($edit) & @CRLF & ">" & $recv)
WEnd


Func _Connect($ipaddr)
    Local $szIPADDRESS = $ipaddr
    Local $nPORT = 33891

    TCPStartup()
    $MainSocket = TCPListen($szIPADDRESS, $nPORT)
    If $MainSocket = -1 Then Exit
    $ConnectedSocket = -1
    
    Do
        $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1
    
    GUICtrlSetData($edit,"Client Connected...")
EndFunc   ;==>Connect

Func _saveOutputToFile($text)
    $file = FileSaveDialog("Save as...",@DesktopDir,"txt (*.txt)|any (*.*)",16,"output_" & random(1,1000) & ".txt")
    if not @error Then
        $fl = FileOpen($file,2)
        FileWrite($fl,$text)
        FileClose($fl)
    EndIf
EndFuncoÝ÷ Ø)bz{ZºÚ"µÍÒ[XÝ
ÛY[
HHÜ[×ÂÑ[ÞBÛÛÝ   ÌÍÔÔHÌÎLBÚ[ÛYH  ÕÚ[ÝÜÐÛÛÝ[Ë]LÉÝÂÚ[ÛYH ÑÝZPÛÛÝ[Ë]LÉÝÂÚ[ÛYH  Ð]ÛÛÛÝ[Ë]LÉÝÂÔYÚ[ÛÈÈÈÕTÛÙHÕRHÙXÝ[ÛÈÈÈÜOBÌÍÑÝZHHÕRPÜX]J  ][ÝÒ[XÝ
ÛY[
HHÜ[×É][ÝË


LKNLËLJBÌÍÜÛHÕRPÝÜX]QY]
    ][ÝÉ][ÝË

KÌÊBÌÍÜÝHÕRPÝÜX]QY]
    ][ÝÉ][ÝËÌ
KMÊBÌÍÔÙ[HÕRPÝÜX]P]Û   ][ÝÔÙ[   ][ÝËMÍÌËÌË   ÌÍÐ×ÑQTÒUÓBÌÍØÒTHÕRPÝÜX]PÛÛXÊ  ][ÝÉÛØØ[   ÝÉ][ÝËMMKJBÕRPÝÙ]]JLK    ][ÝÉÛØØ[   ÝÉ][ÝÊBÌÍØÛÛXÝHÕRPÝÜX]P]Û ][ÝÐÛÛXÝ   ][ÝËNMKLÊBÌÍÙ[[[HHÕRPÝÜX]SY[J  ][ÝÑ[I][ÝÊBÌÍÔØ]UÑ[HHÕRPÝÜX]SY[R][J ][ÝÔØ]HÝ]]È[K][ÝË    ÌÍÙ[[[JBÌÍÑ^]HÕRPÝÜX]SY[R][J   ][ÝÑ^]    ][ÝË  ÌÍÙ[[[JBÌÍÚ[Û[HHÕRPÝÜX]SY[J   ][ÝÒ[É][ÝÊBÌÍØÛÛ[X[ÈHÕRPÝÜX]SY[R][J   ][ÝÒ[ ][ÝÈ  [ÈX    [È ][ÝÑI][ÝË   ÌÍÚ[Û[JBÌÍÝÜ[ÈHÕRPÝÜX]SY[R][J   ][ÝÝÜ[×É][ÝË ÌÍÚ[Û[JBÕRTÙ]Ý]JÕ×ÔÒÕÊBÑ[YÚ[ÛÈÈÈSÛÙHÕRHÙXÝ[ÛÈÈÂÙ[ÛÛXÊ
BÚ[HBTÝÚ]ÚÕRQÙ]ÙÊ
BBXØÙHLÂBBUÔÚ]ÝÛ
BBBQ^]BXØÙH   ÌÍÔÙ[BBQÕRPÝÙ]]J ÌÍÜÝÕRPÝXY
    ÌÍÜÝH   [ÈÜ   [È ][ÝÉÝÉ][ÝÈ    [ÈÝ[ÔXÙJÕRPÝXY
    ÌÍÜÛ
KÔÔ   [È ][ÝÉÝÉ][ÝÊJBBBQÕRPÝÙ]]J    ÌÍÜÛ    ][ÝÉ][ÝÊBBBWÔÙ[
ÕRPÝXY
    ÌÍÜÛ
JBBPØÙH   ÌÍÑ^]BBUÔÚ]ÝÛ
BBBQ^]BPØÙH   ÌÍØÛÛ[X[ÂBB[ÙØÞ
    ][ÝÒ[ ][ÝË  ][ÝÐÛÛ[X[Î][ÝÈ   [ÈÔÂBBI[È   ][ÝËÐÓQXÚÈÚX[È[ÛÉÝØÚX[Û[ÛË
Ù[ÈHÓQÛÛ[X[
I][ÝÈÂBBI[ÈÔ   [È ][ÝËÑSHÎÌLÙ[K
Ù[ÈH[JI][ÝÈÂBBI[ÈÔ   [È ][ÝÜÛÛYH^
Ù[ÈHYÜØYÙJI][ÝÊBBPØÙH  ÌÍÔØ]UÑ[BBBWÜØ]SÝ]]Ñ[JÝZXÝXY
    ÌÍÜÝJBBPØÙH   ÌÍØÛÛXÝBBWÔÝÜPÛÛXÊ
BBBUÔÝ

BBBWØÛÛXÝ
TYÜÌJBQ[ÝÚ]ÚBBBÑ[[ÈØÛÛXÝ
    ÌÍÚYBZY  ÌÍÚYH    ][ÝÉÛØØ[   ÝÉ][ÝÈ[ ÌÍÚYHTYÜÌBYÛØ[   ÌÍÝÜÛÛXÝ[ÛHÔÛÛXÝ
    ÌÍÚY ÌÍÔÔ
BZY ÌÍÝÜÛÛXÝ[ÛHLHÜÜ[BQÕRPÝÙ]]J ÌÍÜÝ    ][ÝÑZ[YÛÛXÝ[Ë ÝÈÔÚ]ÝÛ   ÝÈÜ][ÝÈ    [ÈÜBBUÔÚ]ÝÛ
BBTÛY

BBQÕRPÝÙ]]J  ÌÍÜÝ    ][ÝÉ][ÝÊBQ[ÙBBQÕRPÝÙ]]J ÌÍÜÝ    ][ÝÐÛÛXÝYÈ    ][ÝÈ  [È ÌÍÚYBQ[YB[[Â[ÈÔÙ[
    ÌÍÛYÜØYÙJBUÔÙ[
    ÌÍÝÜÛÛXÝ[Û  ÌÍÛYÜØYÙJBZYLH[Ù]ÜKJB[[Â[ÈÜØ]SÝ]]Ñ[J  ÌÍÝ^
BIÌÍÙ[HH[TØ]QX[ÙÊ ][ÝÔØ]HË][ÝËÚÝÜ    ][ÝÝ


_[H

I][ÝËM    ][ÝÛÝ]]É][ÝÈ  [È[ÛJKL
H   [È ][ÝË  ][ÝÊBZYÝÜ[BIÌÍÙH[SÜ[    ÌÍÙ[KBBQ[UÜ]J   ÌÍÙ  ÌÍÝ^
BBQ[PÛÜÙJ    ÌÍÙ
BQ[Y[[Â[ÈÙ[ÛÛXÊ
BQ[H    ÌÍÛ[HRY[Q^ÝÊØÜ   [È ][ÝÉÌLÒTÓÝ]   ][ÝÊH[BIÌÍÙH[SÜ[ØÜ  [È ][ÝÉÌLÒTÓÝ]   ][ÝË
BBBBQÜ ÌÍÚHHHÈLBBIÌÍÛ[H [ÏH    ][Ýß  ][ÝÈ  [È[TXY[J   ÌÍÙ  ÌÍÚJBBS^BBBQÕRPÝÙ]]J  ÌÍØÒT   ÌÍÛ[JBBQ[PÛÜÙJ    ÌÍÙBQ[Y[[Â[ÈÔÝÜPÛÛXÊ
BIÌÍÙH[SÜ[ØÜ  [È ][ÝÉÌLÒTÓÝ]   ][ÝË
BIÌÍÜXYH[TXY[J   ÌÍÙBQ[PÛÜÙJ   ÌÍÙBBRYÝÝ[Ò[Ý    ÌÍÜXYÝZXÝXY
    ÌÍØÒT
JH[BIÌÍÙH[SÜ[ØÜ   [È ][ÝÉÌLÒTÓÝ]   ][ÝËJBBQ[UÜ]J    ÌÍÙÝZXÝXY
    ÌÍØÒT
H   [ÈÜBBQ[PÛÜÙJ   ÌÍÙBQ[Y[[

can somebody please help ?

thanks in advance :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites



excuse me

I'm an idiot :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

excuse me

I'm an idiot :P

Can you please tell me what the problem was.

I have been trying to debug your code for 10 minutes now and I am going insane :)


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

Share this post


Link to post
Share on other sites

Yes

here it is:

case $Send
            GUICtrlSetData($rcv,GUICtrlRead($rcv) & @crlf & ">" & StringReplace(GUICtrlRead($snd),@CRLF,@CRLF & ">"))
            GUICtrlSetData($snd,"")
            _Send(GUICtrlRead($snd)) ;I was sending nothing XD

and I also had a problem with some variables

now it's all ok :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

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