Jump to content

Recommended Posts

Posted

This code doesn't work when i put TCPListen, but it works when i use TCPConnect.

I am trying to listen to this ip/port for incoming messages, not sure what i am missing.

$ip = "75.150.216.162"
$port = 4099

TCPStartup()

$socket = TCPListen($ip, $port)

While 1
    $recv = TCPRecv ($socket, 5000 )
    If $recv <> "" Then MsgBox ( 4096, "recv", $recv )
WEnd
Posted (edited)

I tried adding a TCPAccept function but TCPListen still wont return anything, however TCPConnect will

$ip = "75.150.216.162"
$port = "4099"

TCPStartup()

$socket = TCPListen($ip, $port)

While 1
    $Accepted = TCPAccept($socket)
    $recv = TCPRecv ($Accepted, 5000 )
    If $recv <> "" Then MsgBox ( 4096, "recv", $recv )
WEnd
Edited by d0n
Posted

What is this IP address? it's yours? or you're trying to listen to another IP address ports, not yours? Again, read the functions description in the help file. Check the return value of a function and write correct code.

Posted

learning TCP is the hard part... after that most times its a breeze

$ip = @IpAddress1 ;"75.150.216.162" try that instead
$port = "4099"

TCPStartup()

$socket = TCPListen($ip, $port, 100);the 100 is the connections (your using the default... maybe thats it

While 1
    $Accepted = TCPAccept($socket)
if $Accepted <> -1 then
    $recv = TCPRecv ($Accepted, 5000 )
    If $recv <> "" Then MsgBox ( 4096, "recv", $recv )
endif
sleep (100)
WEnd
func onautoitexit ()
TCPclosesocket ($Accepted)
TCPshutdown ()
endfunc

i dunno try that out

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
×
×
  • Create New...