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!
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.
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:
Public Const SOCKET_STATE_CLOSED As Integer = 0
Public Const SOCKET_STATE_OPEN As Integer = 1
Public Const SOCKET_STATE_LISTENING As Integer = 2
Public Const SOCKET_STATE_CONNECTION_PENDING As Integer = 3
'Etc.
but I'd sooner define an enumeration:
vb.net Code:
Public Enum SocketState
Closed = 0
Open = 1
Listening = 2
ConnectionPending = 3
'Etc.
End Enum
You can then do something like this:
vb.net Code:
If myAxWinsock.State = SocketState.Open Then
Re: AxWinsock session state constants