Results 1 to 4 of 4

Thread: AxWinsock session state constants

  1. #1

    Thread Starter
    New Member nikoloz's Avatar
    Join Date
    Nov 2020
    Location
    Georgia, Tbilisi
    Posts
    12

    AxWinsock session state constants

    Good evening,

    Can anyone kindly tell me whether AxWinsock session state constants(sckConnected, sckListening, sckOpen etc) are available in Visual Basic 2010 Ultimate?

    If not is there any other means to monitor AxWinsock made connection state(position)?

    Thank you sincere!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: AxWinsock session state constants

    VB.NET supports ActiveX controls so you can use any ActiveX control in VB.NET code, that includes properties, methods and events of that control. That said, you should not be using unmanaged code in VB.NET as a first option. The types in the System.Net.Sockets namespace are specifically dedicated to the task. You should generally use a TcpClient as your first choice and, if you need more fine-grained control, use a Socket.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: AxWinsock session state constants

    The constants you are talking about are simply numbers. Of course numbers are "available". You can just declare the appropriate constants if you want:
    vb.net Code:
    1. Public Const SOCKET_STATE_CLOSED As Integer = 0
    2. Public Const SOCKET_STATE_OPEN As Integer = 1
    3. Public Const SOCKET_STATE_LISTENING As Integer = 2
    4. Public Const SOCKET_STATE_CONNECTION_PENDING As Integer = 3
    5. 'Etc.
    but I'd sooner define an enumeration:
    vb.net Code:
    1. Public Enum SocketState
    2.     Closed = 0
    3.     Open = 1
    4.     Listening = 2
    5.     ConnectionPending = 3
    6.     'Etc.
    7. End Enum
    You can then do something like this:
    vb.net Code:
    1. If myAxWinsock.State = SocketState.Open Then
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member nikoloz's Avatar
    Join Date
    Nov 2020
    Location
    Georgia, Tbilisi
    Posts
    12

    Re: AxWinsock session state constants

    Thank you sincire sir.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width