Jump to content

[Resolved] TCP


Recommended Posts

Could some one post an example of a simple tcp script that sends a message box to another computer?

I cant seem to figure the tcp out

cant figure it out

my code so far

Server

while 1
TCPStartup()
$main = TCPListen(@ipaddress1, 1111)
TCPAccept($main)
If TCPRecv($main, 1000) = "{!}msg" Then
    MsgBox(0,"Test", "Message Sent")
EndIf
WEnd

Client

TCPStartup()
$ip = "72.171.0.147"
$msg = "{!}msg"
$socket = TCPConnect($ip, 1111)
TCPSend($socket, $msg)

I'm assuming my code is way off.

Any help would be appreciated.

Link to comment
Share on other sites

Server

$ip = @ipaddress1;or "0.0.0.0" for all interfaces
$port = 1111
TCPStartup()
$main = TCPListen($ip, $port)
Do
        $socket = TCPAccept($main)
Until $socket <> -1
Do
        $recv = TCPRecv($socket, 17520)
Until $recv <> ""
    
If $recv = "msgbox" Then MsgBox(0,"Test", "Message Sent")
TCPCloseSocket($socket)
TCPShutdown()

Client

$ip = "72.171.0.147"
$port = 1111
$msg = "msgbox"
TCPStartup()
Do
         $socket = TCPConnect($ip, $port)
Until $socket <> -1
sleep(50)
TCPSend($socket, $msg)
If @error Then MsgBox(0,"Error", "Message Failed To send")
TCPShutdown()

Basic Idea not tested

Make sure if you test you have your firewall and what not set up to accept connections on whatever port you set for the server.

Edited by SoulA
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...