Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
where can I get more info about TCP/IP in QB64?
#5
Hi Jack 
you're right! I got this

[Image: Sharing-data-by-TCP-IP.jpg]

with this code
Code: (Select All)

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 running two copies of me at once!)"
    Print "Waiting... (Press any key to end)"
    x = _OpenHost("TCP/IP:1234")
    If x = 0 Then Print "failure to create host" Else Print "Host ON"
    Do
        z = _OpenConnection(x)
        If z <> 0 Then
            Put #z, , a() 'send array a to any client that connects
            Close z
            Print "Array data send to client!"
        Else
            Print "Failure connection"
        End If
        _Limit 10
    Loop Until InKey$ <> ""
    Print "Finished!"
    End
End If

'connect to host as a client
Print "Conected to host. Reading data..."
Do
    Get #x, , a()
    _Limit 100
Loop Until EOF(x) = 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 x
Print "That's how you share data folks!" 'G@lleon
PS the debug message is mine, not of origiinal code.
Reply


Messages In This Thread
RE: where can I get more info about TCP/IP in QB64? - by TempodiBasic - 08-02-2024, 08:51 AM



Users browsing this thread: 1 Guest(s)