Jump to content

TCPlisten


 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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...