Jump to content
Sign in to follow this  

TCP Chat help =P

Recommended Posts


: EDIT I solved my last problem that was previously on this thread so I changed it:

I have a little console program and I want it to also send & recieve messages, although, posting it here would vause you to have to read 500+ lines, and so, I won't post it.

I'm not sure why tis wont work, but it may be becasue of one of these:

a) LAN

:) I didn't code it right

c) I should be using WAN rather then my LAN address

Any way, I looked at the example forum and saw this thing on remote autoit, and I dissected it and stole some parts(the following is my script):

($input1 is my input box)

($interface is a edit box)

($button1 is my send button)

$Ip = @IPAddress1
$Port = 5900
$Incoming = TCPListen($Ip, $Port)

;gui stuff here

While 1
If $ALLOWCHAT = True Then
    $Con = TCPAccept($Incoming)
    $msg = TCPRecv($con, 5000)
    If $msg <> "" Then
        GUICtrlSetData($Interface, GUICtrlRead($Interface) & @CRLF & $msg)

;alot of script here

        Case $Button1
            If $CLEAR = True Then GUICtrlSetData($Interface, "")
            $CMD = GUICtrlRead($Input1)
            $last = GUICtrlRead($Input1)
            $CMDLN = StringTrimRight($CMD, StringLen($CMD) - 5)
            GUICtrlSetData($Input1, "")
            GUICtrlSetData($Interface, GUICtrlRead($Interface) & @CRLF & "[" & $USER & "]: " & $CMD)
                Case $CMDLN = "/snd "
                    If $ALLOWCHAT = True Then
                    TCPSend($con2, "[" & $USER & "]: " & StringTrimLeft($CMD, 5))
                    GUICtrlSetData($Interface, GUICtrlRead($Interface) & @CRLF & "-Chat is disabled")

;about 300 more lines of script here

        Case $MenuItem26
            If $ALLOWCHAT = False Then
                GUICtrlSetState($MenuItem26, $GUI_CHECKED)
                $ALLOWCHAT = True
                $ip2 = InputBox("IP", "Enter IP to connect to", @IPAddress1)
                $port2 = InputBox("Port", "What port are they using?", "5900")
                $con2 = TCPConnect($ip, $port)
                GUICtrlSetState($MenuItem26, $GUI_UNCHECKED)
                $ALLOWCHAT = False

OK, so $ALLOWCHAT is false at start, then you clicksomething ($menuitem26) and it'll switch $ALLOWCHAT to TRUE, then ask you for what to connect to, and ALSO by switching on $ALLOWCHAT, the script SHOULD start writing anything incomming to the $interface, and also, you SHOULD be able to type (/snd <text>) and click $button1 and it SHOULD have sent it to the address you typed earlier when you allowed chat...

problem is, it DOESN'T do what it SHOULD..

and I'm lost here XD

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.