Winsock.state? 
Author Message
 Winsock.state?

what the heck is this property and how do u use it?
thanks
please e-mail me:



Mon, 24 Jun 2002 03:00:00 GMT  
 Winsock.state?
There exists a pretty good explanation of this at
<http://msdn.microsoft.com/library/devprods/vs6/vbasic/mswnsk98/vbpros...
te.htm>...

Anyway, I can tell you that this property is the mother of all use of this
control.  The Winsock control acts asynchronously, so you can't just say
Winsock.Connect and immedately thereafter, say Winsock.SendData.  Instead,
you have to waste a few CPU cycles while it connects to the remote machine,
and then you can execute the SendData method.  In order to tell if it is
fully connected or not, you must check the Winsock.State property and see if
it equals sckConnected.

Howard Henry Schlunder


Quote:
> what the heck is this property and how do u use it?
> thanks
> please e-mail me:




Mon, 24 Jun 2002 03:00:00 GMT  
 Winsock.state?
heya,
        here is a procedure i like to use, which assumes you have a winsok
control (wskMBX) and a status bar (sbrMBX):

Public Sub RefreshSocket()

Dim r As Integer

Select Case wskMBX.State

Case sckClosed   '0   Default. Closed
sbrMBX.Panels(1).Text = "Closed"

Case sckOpen '1   Open
sbrMBX.Panels(1).Text = "Connected to " & wskMBX.RemoteHostIP & " (" &
wskMBX.RemotePort & ")"

Case sckListening    '2   Listening
sbrMBX.Panels(1).Text = "Listening..."

Case sckConnectionPending   '3   Connection pending
sbrMBX.Panels(1).Text = "Connecting..."

Case sckResolvingHost    '4   Resolving host
sbrMBX.Panels(1).Text = "Resolving..."

Case sckHostResolved     '5   Host resolved
sbrMBX.Panels(1).Text = "Resolved"

Case sckConnecting   '6   Connecting
sbrMBX.Panels(1).Text = "Connecting..."

Case sckConnected    '7   Connected
sbrMBX.Panels(1).Text = "Connected to " & wskMBX.RemoteHostIP & " (" &
wskMBX.RemotePort & ")"

Case sckClosing  '8   Peer is closing the connection
sbrMBX.Panels(1).Text = "Closing..."
cmdConnect.Caption = "&Connect"
wskMBX.Close
RefreshSocket

Case sckError    '9   Error
sbrMBX.Panels(1).Text = "Error!"
r = MsgBox("A message has occurred. The error was " & ErrorMessage & " - ("
& ErrorNumber & ")", vbOKOnly + vbInformation, "MKII Mailbox Viewer")
wskMBX.Close
RefreshSocket

End Select

End Sub

    put RefreshSocket in every event of the winsok control like this:

Private Sub wskMBX_Error(ByVal Number As Integer, Description As String,
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal
HelpContext As Long, CancelDisplay As Boolean)

ErrorMessage = Description
ErrorNumber = Number
Socket

End Sub

    of course, only include the error settings in this event...

    cheers,

                carl

    http://www.mkii.net


Quote:
> what the heck is this property and how do u use it?
> thanks
> please e-mail me:




Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Winsock.state?

2. Winsock State

3. what is each number in winsock state mean ?

4. Winsock state

5. what is each number in winsock state mean ?

6. winsock state = 4

7. problems to connect, winsock.state = 6 ??

8. winsock.state ?

9. Winsock state

10. VB 5.0 Winsock States ....

11. VB6 MSWinSck.ocx Winsock.State=sckClosing

12. about winsock.state

 

 
Powered by phpBB® Forum Software