09-20-2024, 10:50 PM
Is it so corrrect?
I dont know if so is it correct. First send data to port 1234 and next receive data from 8080?
Code: (Select All)
$Unstable:Http
Screen _NewImage(512, 512, 256)
Dim a(511, 511) As Integer 'an array we'll send
x = _OpenClient("TCP/IP:1234:localhost") 'try to connect to a host
If x = 0 Then 'couldn't be client, so become a host
'put some data into array a
For xx = 0 To 511
For yy = 0 To 511
a(xx, yy) = xx * yy
Next
Next
Print "(Try passing data via TCP/IP!)"
Print "Waiting... (Press any key to end)"
x = _OpenHost("TCP/IP:8080")
If x = 0 Then Print "failure to create host" Else Print "Host ON"
End If
x2 = _OpenClient("TCP/IP:8080:localhost") 'try to connect to a host
Print x2
If x2 < 0 Then
z = _OpenConnection(x)
Print "z"; z
'connect to host as a client
If z < 0 Then
Print "Connected to host. Reading data..."
Do
Put #z, , a() 'send array a to any client that connects
Close z
Print "Array data send to client!"
Get #x2, , a()
_Limit 100
Loop Until EOF(x2) = 0 'wait until enough data to fill the array arrives
For xx = 0 To 511
For yy = 0 To 511
PSet (xx, yy), a(xx, yy)
Next
Next
Close x2
Print "That's how you share data folks!" 'G@lleon
Do: Loop Until InKey$ = ""
Else
Print "Failure connection with z "; z
End If
_Limit 10
Print "Finished!"
End
Else
Print "Failure to create host client connection "; x2
End If
End
I dont know if so is it correct. First send data to port 1234 and next receive data from 8080?