'This sample shows how to use the Winsock control. 'For real world apps, you'll want to do more error checking. AddObject "mswinsock.winsock","ws" Sub CommandButton1_Click Dim strData getState ws.remotehost=fldRemoteHost.text ws.remoteport=fldPort.text connect strdata="GET " & fldURL.text & chr(10) getState ws.SendData strData getState End Sub Sub ws_sendComplete() getState fldMessages.text=fldMessages.text & "sendComplete event received" & vbcrlf End Sub Sub ws_DataArrival(byval bytesTotal) Dim rdata fldMessages.text=fldMessages.text & "data arrival " & bytesTotal & vbcrlf getstate If ws.state=7 Then ws.getData rData, vbString, bytesTotal rData = replace(rData, chr(10), vbcrlf) fldMessages.text=fldMessages.text & rData End If End Sub Sub connect() 'need to wait for connection Dim limit limit=dateadd("s",5,now) ws.connect Do While (ws.state<>7) And (now7 Then MsgBox "Could not connect." End Sub Sub ws_error(code, desc, Scode, Source, Helpfile, HelpContext, CancelDisplay) fldMessages.text=fldMessages.text & "winsock error:" & code & " " & description & vbcrlf End Sub Sub getState() Select Case ws.state Case 0: fldState.text="Closed" Case 1: fldState.text="Open" Case 2: fldState.text="Listening" Case 3: fldState.text="Connection Pending" Case 4: fldState.text="Resolving Host" Case 5: fldState.text="Host Resolved" Case 6: fldState.text="Connecting" Case 7: fldState.text="Connected" Case 8: fldState.text="Peer is closing" Case 9: fldState.text="Error" End Select doEvents End Sub