VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Function to return winsocks current connection state as a string

by BP (8 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code will return to you the state of the current winsock function in english rather than a number.. etc, "connected", "resolving host", etc.

Rate Function to return winsocks current connection state as a string

Public Function GetSockState(winsock1 as winsock) as String
  If winsock1.State = 0 Then
    GetSockState = "Connection Closed"
  ElseIf winsock1.State = 1 Then
    GetSockState = "Connection Open"
  ElseIf winsock1.State = 2 Then
    GetSockState = "Connection Listening"
  ElseIf winsock1.State = 3 Then
    GetSockState = "Connection Pending"
  ElseIf winsock1.State = 4 Then
    GetSockState = "Resolving Host"
  ElseIf winsock1.State = 5 Then
    GetSockState = "Host Resolved"
  ElseIf winsock1.State = 6 Then
    GetSockState = "Connecting"
  ElseIf winsock1.State = 7 Then
    GetSockState = "Connected"
  ElseIf winsock1.State = 8 Then
    GetSockState = "Peer is closing the connection"
  ElseIf winsock1.State = 9 Then
    GetSockState = "Error"
  End If
End Sub

Download this snippet    Add to My Saved Code

Function to return winsocks current connection state as a string Comments

No comments have been posted about Function to return winsocks current connection state as a string. Why not be the first to post a comment about Function to return winsocks current connection state as a string.

Post your comment

Subject:
Message:
0/1000 characters