Sign in to follow this  
Followers 0
MirnesC2

TCP question

6 posts in this topic

Client

TCPStartup()

$TCPConnect = TCPConnect(@IPAddress1, 403)

If $TCPConnect = -1 Then Exit

TCPSend($TCPConnect, "Hello")

Server

TCPStartup()

$TCPListen = TCPListen(@IPAddress1, 403)

Do
    $TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

Do
    $TCPRecive = TCPRecv($TCPAccept, 1000000)
Until $TCPRecive <> ""

MsgBox(0, "Data recived", $TCPRecive)

Ok so I watched a tutorial online and was able to string this together. What it does is send "hello" into a message box. This only sends data from my pc to my pc. How can I make it so that I can send "Hello" from my pc to someone elses pc? Whos IP addresses do I use in each field? What port?

Share this post


Link to post
Share on other sites



On the server-side, @IPAddress1 is the address that the server is listening for connections on, so that can remain unchanged.

On the client-side, you want the address of the server to connect to, so change that to the address of the one running the server-side.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

So...

PersonB is running server.

PersonA is running client.

PersonA needs to change the IP to PersonB 's IP in the client.au3?

PersonB leaves @IPAddress1 as it is under server.au3?

and this will allow PersonA to send a message to PersonB? Correct?

Also which IP is being used? Is there a macro? ( like @IP2)

Share this post


Link to post
Share on other sites

So...

PersonB is running server.

PersonA is running client.

PersonA needs to change the IP to PersonB 's IP in the client.au3?

PersonB leaves @IPAddress1 as it is under server.au3?

and this will allow PersonA to send a message to PersonB? Correct?

Also which IP is being used? Is there a macro? ( like @IP2)

um well you will have to know the server's ip(@ipadress1 on server computer) so that the client cud connect to it.. yo can check out the tic tac toe in my signature that uses tcp.. such that the client and server software is the same

Share this post


Link to post
Share on other sites

I modified it a bit so I can learn more about it but it doesn't seem to work the way I want it to.

CLIENT

#include <GUIConstantsEx.au3>

GUICreate("TCPClient",180,40)
GUISetState(@SW_SHOW)

$packet = GUICtrlCreateInput("",10,10,90,20)
$send = GUICtrlCreateButton("Send",110,10,60,20)

TCPStartup()

$TCPConnect = TCPConnect(@IPAddress1, 403)

If $TCPConnect = -1 Then Exit



While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $send
            TCPSend($TCPConnect, GUICtrlRead($packet))
    EndSwitch
WEnd

SERVER

TCPStartup()

$TCPListen = TCPListen(@IPAddress1, 403)



While 1
    Do
    $TCPAccept = TCPAccept($TCPListen)
    Until $TCPAccept <> -1

    Do
        $TCPRecive = TCPRecv($TCPAccept, 1000000)
    Until $TCPRecive <> ""

    MsgBox(0, "Data recived", $TCPRecive)

    If $TCPRecive = "exit" Then
        ExitLoop
    EndIf

    $TCPAccept = -1
    $TCPRecive = ""
WEnd

I want to to be able to send message after message until TCPRecive(the message) = exit.

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