I’m using Xojo to test a TCP server utility. The Xojo project, at the moment, is relatively simple; a form that lets me enter a port and an address, click connect, then it sends strings to the server which echos back a response that is displayed in another textbox.
If the server isn’t running when I click connect, the interface locks up while I assume it’s waiting to time out…it’s running on the Mac, so all I have in the Xojo window is a spinning beachball.
Is there an idiomatic way to avoid this, so I could quit the connection process if necessary?
The connect button has this in the Action handler:
[code]Dim port as Integer
// Status update
lblStatusText.Value = “Initializing socket”
App.socket = new TCPSocket
// Status update
lblStatusText.Value = “Setting address and port”
App.socket.Address = ComboBoxConServer.Value
port = Val(ComboBoxConPort.Value)
App.socket.Port = port
// Status update
lblStatusText.Value = "Server: " + ComboBoxConServer.Value + ", Port: " + ComboBoxConPort.Value
// Connect the socket
App.socket.Connect
// while the socket isn’t connected
While Not App. socket.IsConnected
// Error check
If App.socket.LastErrorCode <> 0 Then
lblStatusText.Value = "Error: " + Str(App.socket.LastErrorCode)
End
// poll the socket to let it do its thing
App.socket.Poll
// if an error occurs, the Error event will fire
Wend
// Status update
lblStatusText.Value = “Connected”
// Open the debugging window
winTest.Visible = True[/code]