Sign in to follow this  
Followers 0
poisonkiller

2 TCP connections

2 posts in this topic

#1 ·  Posted (edited)

First i need TCP connection for listen and if something like "string" comes from server, then first TCP closes and another starts on another IP. Ok i try to do example:

TCPStartup()
$connectedSocket = TCPConnect("First IP", 666)
$MainSocket = TCPListen("First IP", 666)

While 1
Do
    $ConnectedSocket = TCPAccept($MainSocket)
  Until $ConnectedSocket > 0
$err = 0
  Do
    $msg = TCPRecv($ConnectedSocket,512)
    $err = @error
If $msg = "string" Then
;TCPCloseSocket($ConnectedSocket)     I dont know if i need this
;Here i need a new TCP connection with IP address "Second IP" and port 666
EndIf
Until $err
TCPCloseSocket($ConnectedSocket)
Wend
TCPShutdown()

I hope someone understand what i need!

Thanks!

EDIT: I solved my problem

Edited by poisonkiller

Share this post


Link to post
Share on other sites



TCPStartup()
$ConnectedSocket = TCPConnect("First IP", 666)
$MainSocket = TCPListen("First IP", 666)
While 1
Do
    $MainSocket = TCPAccept($MainSocket)
Until $ConnectedSocket > 0
$err = 0
  Do
    $msg = TCPRecv($MainSocket,512)
    $err = @error
    $msg = StringSplit($msg, "-")
    If $msg[1] = "~newconnect" Then
        TCPCloseSocket($ConnectedSocket)
        TCPOpen($msg[2], 666)
    EndIf
Until $err 
TCPCloseSocket($ConnectedSocket)
TCPCloseSocket($MainSocket)
Wend
TCPShutdown()

Is this what you would like? Syntax is ~newconnect-(IpAddress)

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