Option Strict On ''' ''' Provides data for the Winsock.ErrorReceived event. ''' Public Class WinsockErrorReceivedEventArgs Inherits System.EventArgs Private m_errorMsg As String Private m_function As String Private m_errorCode As System.Net.Sockets.SocketError Private m_Details As String ''' ''' Initializes a new instance of the WinsockErrorEventArgs class. ''' ''' A String containing the error message. Public Sub New(ByVal error_message As String) Me.New(error_message, Nothing) End Sub ''' ''' Initializes a new instance of the WinsockErrorEventArgs class. ''' ''' A String containing the error message. ''' A String containing the name of the function that produced the error. Public Sub New(ByVal error_message As String, ByVal function_name As String) Me.New(error_message, function_name, Nothing) End Sub ''' ''' Initializes a new instance of the WinsockErrorEventArgs class. ''' ''' A String containing the error message. ''' A String containing the name of the function that produced the error. ''' A String containing extra details for the error message. Public Sub New(ByVal error_message As String, ByVal function_name As String, ByVal extra_details As String) Me.New(error_message, function_name, extra_details, Net.Sockets.SocketError.Success) End Sub ''' ''' Initializes a new instance of the WinsockErrorEventArgs class. ''' ''' A String containing the error message. ''' A String containing the name of the function that produced the error. ''' A String containing extra details for the error message. ''' A value containing the socket's ErrorCode. Public Sub New(ByVal error_message As String, ByVal function_name As String, ByVal extra_details As String, ByVal error_code As System.Net.Sockets.SocketError) m_errorMsg = error_message m_function = function_name m_Details = extra_details m_errorCode = error_code End Sub ''' ''' Gets a value containing the error message. ''' Public ReadOnly Property Message() As String Get Return m_errorMsg End Get End Property ''' ''' Gets a value containing the name of the function that produced the error. ''' Public ReadOnly Property [Function]() As String Get Return m_function End Get End Property ''' ''' Gets a value indicating the error code returned by the socket. ''' ''' If it wasn't returned by the socket, it defaults to success. Public ReadOnly Property ErrorCode() As System.Net.Sockets.SocketError Get Return m_errorCode End Get End Property ''' ''' Gets a value containing more details than the typical error message. ''' Public ReadOnly Property Details() As String Get Return m_Details End Get End Property End Class ''' ''' Provides data for the Winsock.ConnectionRequest event. ''' Public Class WinsockConnectionRequestEventArgs Inherits System.EventArgs Private _client As System.Net.Sockets.Socket Private _cancel As Boolean = False ''' ''' Initializes a new instance of the WinsockClientReceivedEventArgs class. ''' ''' A Socket object containing the new client that needs to be accepted. Public Sub New(ByVal new_client As System.Net.Sockets.Socket) _client = new_client End Sub ''' ''' Gets a value containing the client information. ''' ''' Used in accepting the client. Public ReadOnly Property Client() As System.Net.Sockets.Socket Get Return _client End Get End Property ''' ''' Gets a value containing the incoming clients IP address. ''' Public ReadOnly Property ClientIP() As String Get Dim rEP As System.Net.IPEndPoint = CType(_client.RemoteEndPoint, System.Net.IPEndPoint) Return rEP.Address.ToString() End Get End Property ''' ''' Gets or sets a value indicating whether the incoming client request should be cancelled. ''' Public Property Cancel() As Boolean Get Return _cancel End Get Set(ByVal value As Boolean) _cancel = value End Set End Property End Class ''' ''' Provides data for the Winsock.StateChanged event. ''' Public Class WinsockStateChangedEventArgs Inherits System.EventArgs Private m_OldState As WinsockStates Private m_NewState As WinsockStates ''' ''' Initializes a new instance of the WinsockStateChangingEventArgs class. ''' ''' The old state of the Winsock control. ''' The state the Winsock control is changing to. Public Sub New(ByVal oldState As WinsockStates, ByVal newState As WinsockStates) m_OldState = oldState m_NewState = newState End Sub ''' ''' Gets a value indicating the previous state of the Winsock control. ''' Public ReadOnly Property Old_State() As WinsockStates Get Return m_OldState End Get End Property ''' ''' Gets a value indicating the new state of the Winsock control. ''' Public ReadOnly Property New_State() As WinsockStates Get Return m_NewState End Get End Property End Class ''' ''' Provides data for the Winsock.DataArrival event. ''' Public Class WinsockDataArrivalEventArgs Inherits System.EventArgs Private _bTotal As Integer Private _IP As String Private _Port As Integer ''' ''' Initializes a new instance of the WinsockDataArrivalEventArgs class. ''' ''' The number of bytes that were received. ''' The source address of the bytes. ''' The source port of the bytes. Public Sub New(ByVal bytes_total As Integer, ByVal source_ip As String, ByVal source_port As Integer) _bTotal = bytes_total _IP = source_ip _Port = source_port End Sub ''' ''' Gets a value indicating the number of bytes received. ''' Public ReadOnly Property TotalBytes() As Integer Get Return _bTotal End Get End Property ''' ''' Gets a value indicating the data's originating address. ''' Public ReadOnly Property SourceIP() As String Get Return _IP End Get End Property ''' ''' Gets a value indicating the data's originating port. ''' Public ReadOnly Property SourcePort() As Integer Get Return _Port End Get End Property End Class ''' ''' Provides data for the Winsock.Connected event. ''' Public Class WinsockConnectedEventArgs Inherits System.EventArgs Private _IP As String Private _Port As Integer ''' ''' Initializes a new instance of the WinsockConnectedEventArgs class. ''' ''' The source address of the connection. ''' The source port of the connection. Public Sub New(ByVal source_ip As String, ByVal source_port As Integer) _IP = source_ip _Port = source_port End Sub ''' ''' Gets a value indicating the remote address of the connection. ''' Public ReadOnly Property SourceIP() As String Get Return _IP End Get End Property ''' ''' Gets a value indicating the remote port of the connection. ''' Public ReadOnly Property SourcePort() As Integer Get Return _Port End Get End Property End Class ''' ''' Provides data for the Winsock.SendComplete event. ''' Public Class WinsockSendEventArgs Inherits System.EventArgs Private _bTotal As Integer Private _bSent As Integer Private _IP As String ''' ''' Initializes a new instance of the WinsockSendEventArgs class. ''' ''' The destination of the bytes sent. ''' The total number of bytes sent. ''' The total number of bytes that were supposed to be sent. Public Sub New(ByVal dest_ip As String, ByVal bytes_sent As Integer, ByVal bytes_total As Integer) _IP = dest_ip _bTotal = bytes_total _bSent = bytes_sent End Sub ''' ''' Gets a value indicating the destination of the bytes sent. ''' Public ReadOnly Property DestinationIP() As String Get Return _IP End Get End Property ''' ''' Gets a value indicating the number of bytes sent. ''' Public ReadOnly Property BytesSent() As Integer Get Return _bSent End Get End Property ''' ''' Gets a value indicating the total number of bytes that should have been sent. ''' Public ReadOnly Property BytesTotal() As Integer Get Return _bTotal End Get End Property ''' ''' Gets a value indicating the percentage (0-100) of bytes that where sent. ''' Public ReadOnly Property SentPercent() As Double Get Return (_bSent / _bTotal) * 100 End Get End Property End Class ''' ''' Provides data for the WinsockCollection.CountChanged event. ''' Public Class WinsockCollectionCountChangedEventArgs Inherits System.EventArgs Private _oldCount As Integer Private _newCount As Integer ''' ''' Initializes a new instance of the WinsockCollectionCountChangedEventArgs class. ''' ''' The old number of items in the collection. ''' The new number of items in the collection. Public Sub New(ByVal old_count As Integer, ByVal new_count As Integer) _oldCount = old_count _newCount = new_count End Sub ''' ''' Gets a value indicating the previous number of items in the collection. ''' Public ReadOnly Property OldCount() As Integer Get Return _oldCount End Get End Property ''' ''' Gets a value indicating the current number of items in the collection. ''' Public ReadOnly Property NewCount() As Integer Get Return _newCount End Get End Property End Class ''' ''' Provides data for the Winsock.ReceiveProgress event. ''' Public Class WinsockReceiveProgressEventArgs Inherits System.EventArgs Private _bTotal As Integer Private _bIn As Integer Private _IP As String ''' ''' Initializes a new instance of the WinsockReceiveProgressEventArgs class. ''' ''' The source ip of the bytes received. ''' The total number of bytes received. ''' The total number of bytes that were supposed to be received. Public Sub New(ByVal source_ip As String, ByVal bytes_received As Integer, ByVal bytes_total As Integer) _IP = source_ip _bTotal = bytes_total _bIn = bytes_received End Sub ''' ''' Gets a value indicating the source of the bytes sent. ''' Public ReadOnly Property SourceIP() As String Get Return _IP End Get End Property ''' ''' Gets a value indicating the number of bytes received. ''' Public ReadOnly Property BytesReceived() As Integer Get Return _bIn End Get End Property ''' ''' Gets a value indicating the total number of bytes that should be received. ''' Public ReadOnly Property BytesTotal() As Integer Get Return _bTotal End Get End Property ''' ''' Gets a value indicating the percentage (0-100) of bytes that where received. ''' Public ReadOnly Property ReceivedPercent() As Double Get Return (_bIn / _bTotal) * 100 End Get End Property End Class