亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? csocketmaster.cls

?? I implemented a perfect file transfer OCX client/server. I created a perfect function to parse and s
?? CLS
?? 第 1 頁 / 共 4 頁
字號:
    Dim arrIpAddress(1 To 4) As Byte
    Dim lngRemoteHostAddress As Long
    Dim Count As Integer
    Dim strIpAddress As String
    
    api_CopyMemory udtHostent, ByVal m_lngMemoryPointer, LenB(udtHostent)
    api_CopyMemory lngPtrToIP, ByVal udtHostent.hAddrList, 4
    api_CopyMemory arrIpAddress(1), ByVal lngPtrToIP, 4
    api_CopyMemory lngRemoteHostAddress, ByVal lngPtrToIP, 4
    
    'free memory, won't need it any longer
    FreeMemory
    
    'We turn the 32 bits long into a readable string.
    'Note: we don't need this string. I put this here just
    'in case you need it.
    For Count = 1 To 4
        strIpAddress = strIpAddress & arrIpAddress(Count) & "."
    Next
        
    strIpAddress = Left$(strIpAddress, Len(strIpAddress) - 1)
    
    ConnectToIP lngRemoteHostAddress, 0
    
Else 'there were errors trying to resolve the hostname

    'free buffer memory
    FreeMemory
    
    ConnectToIP vbNull, lngErrorCode

End If
End Sub

'This procedure is called by the WindowProc callback function.
'The lngEventID argument is an ID of the network event
'occurred for the socket. The lngErrorCode argument contains
'an error code only if an error was occurred during an
'asynchronous execution.
Private Sub PostSocket(ByVal lngEventID As Long, ByVal lngErrorCode As Long)

Dim blnCancelDisplay As Boolean

'handle any possible error
If lngErrorCode <> 0 Then
    m_enmState = sckError: Debug.Print "STATE: sckError"
    blnCancelDisplay = True
    RaiseEvent Error(lngErrorCode, GetErrorDescription(lngErrorCode), 0, "CSocketMaster.PostSocket", "", 0, blnCancelDisplay)
    If blnCancelDisplay = False Then MsgBox GetErrorDescription(lngErrorCode), vbOKOnly, "CSocketMaster.PostSocket"
    Exit Sub
End If

Dim udtSockAddr As sockaddr_in
Dim lngResult As Long
Dim lngBytesReceived As Long

Select Case lngEventID

'======================================================================

Case FD_CONNECT

    'Arrival of this message means that the connection initiated by the call
    'of the connect Winsock API function was successfully established.

    Debug.Print "FD_CONNECT " & m_lngSocketHandle
    
    If m_enmState <> sckConnecting Then
        Debug.Print "WARNING: Omitting FD_CONNECT"
        Exit Sub
    End If
    
    'Get the local parameters
    GetLocalInfo m_lngSocketHandle, m_lngLocalPortBind, m_strLocalIP
   
    'Get the connection local end-point parameters
    GetRemoteInfo m_lngSocketHandle, m_lngRemotePort, m_strRemoteHostIP, m_strRemoteHost
    
    m_enmState = sckConnected: Debug.Print "STATE: sckConnected"
    RaiseEvent Connect

'======================================================================

Case FD_WRITE

    'This message means that the socket in a write-able
    'state, that is, buffer for outgoing data of the transport
    'service is empty and ready to receive data to send through
    'the network.
    
    Debug.Print "FD_WRITE " & m_lngSocketHandle
    
    If m_enmState <> sckConnected Then
        Debug.Print "WARNING: Omitting FD_WRITE"
        Exit Sub
    End If
    
    If Len(m_strSendBuffer) > 0 Then
        SendBufferedData
    End If
    
'======================================================================

Case FD_READ

    'Some data has arrived for this socket.

    Debug.Print "FD_READ " & m_lngSocketHandle
    
    If m_enmProtocol = sckTCPProtocol Then
        
        If m_enmState <> sckConnected Then
            Debug.Print "WARNING: Omitting FD_READ"
            Exit Sub
        End If
        
        'Call the RecvDataToBuffer function that move arrived data
        'from the Winsock buffer to the local one and returns number
        'of bytes received.
    
        lngBytesReceived = RecvDataToBuffer
    
        If lngBytesReceived > 0 Then
            RaiseEvent DataArrival(Len(m_strRecvBuffer))
        End If
    
    Else 'UDP protocol
        
        If m_enmState <> sckOpen Then
            Debug.Print "WARNING: Omitting FD_READ"
            Exit Sub
        End If
        
        'If we use UDP we don't remove data from winsock buffer.
        'We just let the user know the amount received so
        'he/she can decide what to do.
        
        lngBytesReceived = GetBufferLenUDP
        
        If lngBytesReceived > 0 Then
            RaiseEvent DataArrival(lngBytesReceived)
        End If
        
        
        'Now the buffer is emptied no matter what the user
        'dicided to do with the received data
        EmptyBuffer
    End If
    
    
'======================================================================

Case FD_ACCEPT

    'When the socket is in a listening state, arrival of this message
    'means that a connection request was received. Call the accept
    'Winsock API function in order to create a new socket for the
    'requested connection.
  
    Debug.Print "FD_ACCEPT " & m_lngSocketHandle
    If m_enmState <> sckListening Then
        Debug.Print "WARNING: Omitting FD_ACCEPT"
        Exit Sub
    End If
    
    lngResult = api_accept(m_lngSocketHandle, udtSockAddr, LenB(udtSockAddr))
    
    If lngResult = INVALID_SOCKET Then
        lngErrorCode = Err.LastDllError
        m_enmState = sckError: Debug.Print "STATE: sckError"
        blnCancelDisplay = True
        RaiseEvent Error(lngErrorCode, GetErrorDescription(lngErrorCode), 0, "CSocketMaster.PostSocket", "", 0, blnCancelDisplay)
        If blnCancelDisplay = False Then MsgBox GetErrorDescription(lngErrorCode), vbOKOnly, "CSocketMaster.PostSocket"
    Else
        'We assign a temporal instance of CSocketMaster to
        'handle this new socket until user accepts (or not)
        'the new connection
        modSocketMaster.RegisterAccept lngResult
        
        'We change remote info before firing ConnectionRequest
        'event so the user can see which host is trying to
        'connect.
        
        Dim lngTempRP As Long
        Dim strTempRHIP As String
        Dim strTempRH As String
        lngTempRP = m_lngRemotePort
        strTempRHIP = m_strRemoteHostIP
        strTempRH = m_strRemoteHost
        
        m_strRemoteHost = ""
        
        GetRemoteInfo lngResult, m_lngRemotePort, m_strRemoteHostIP, m_strRemoteHost
        
        Debug.Print "OK Accepted socket: " & lngResult
        RaiseEvent ConnectionRequest(lngResult)
        
        'we return original info
        If m_enmState = sckListening Then
             m_lngRemotePort = lngTempRP
             m_strRemoteHostIP = strTempRHIP
             m_strRemoteHost = strTempRH
        End If
        
        'This is very important. If the connection wasn't accepted
        'we must close the socket.
        If IsAcceptRegistered(lngResult) Then
            api_closesocket lngResult
            modSocketMaster.UnregisterSocket lngResult
            modSocketMaster.UnregisterAccept lngResult
            Debug.Print "OK Closed accepted socket: " & lngResult
        End If
    End If
    
'======================================================================
    
Case FD_CLOSE
    
    'This message means that the remote host is closing the conection
    
    Debug.Print "FD_CLOSE " & m_lngSocketHandle
    
    If m_enmState <> sckConnected Then
        Debug.Print "WARNING: Omitting FD_CLOSE"
        Exit Sub
    End If
    
    m_enmState = sckClosing: Debug.Print "STATE: sckClosing"
    RaiseEvent CloseSck
    
End Select
End Sub

'Connect to a given 32 bits long ip
Private Sub ConnectToIP(ByVal lngRemoteHostAddress As Long, ByVal lngErrorCode As Long)

Dim blnCancelDisplay As Boolean

'Check and handle errors
If lngErrorCode <> 0 Then
    m_enmState = sckError: Debug.Print "STATE: sckError"
    blnCancelDisplay = True
    RaiseEvent Error(lngErrorCode, GetErrorDescription(lngErrorCode), 0, "CSocketMaster.ConnectToIP", "", 0, blnCancelDisplay)
    If blnCancelDisplay = False Then MsgBox GetErrorDescription(lngErrorCode), vbOKOnly, "CSocketMaster.ConnectToIP"
    Exit Sub
End If

Debug.Print "OK Connecting to: " + m_strRemoteHost + " " + m_strRemoteHostIP
m_enmState = sckConnecting: Debug.Print "STATE: sckConnecting"

Dim udtSockAddr As sockaddr_in
Dim lngResult As Long

'Build the sockaddr_in structure to pass it to the connect
'Winsock API function as an address of the remote host.
With udtSockAddr
    .sin_addr = lngRemoteHostAddress
    .sin_family = AF_INET
    .sin_port = api_htons(modSocketMaster.UnsignedToInteger(m_lngRemotePort))
End With

'Call the connect Winsock API function in order to establish connection.
lngResult = api_connect(m_lngSocketHandle, udtSockAddr, LenB(udtSockAddr))

'Check and handle errors
If lngResult = SOCKET_ERROR Then
    lngErrorCode = Err.LastDllError
    If lngErrorCode <> WSAEWOULDBLOCK Then
        If lngErrorCode = WSAEADDRNOTAVAIL Then
            Err.Raise WSAEADDRNOTAVAIL, "CSocketMaster.ConnectToIP", GetErrorDescription(WSAEADDRNOTAVAIL)
        Else
            m_enmState = sckError: Debug.Print "STATE: sckError"
            blnCancelDisplay = True
            RaiseEvent Error(lngErrorCode, GetErrorDescription(lngErrorCode), 0, "CSocketMaster.ConnectToIP", "", 0, blnCancelDisplay)
            If blnCancelDisplay = False Then MsgBox GetErrorDescription(lngErrorCode), vbOKOnly, "CSocketMaster.ConnectToIP"
        End If
    End If
End If

End Sub

Public Sub Bind(Optional LocalPort As Variant, Optional LocalIP As Variant)
If m_enmState <> sckClosed Then
    Err.Raise sckInvalidOp, "CSocketMaster.Bind", "Invalid operation at current state"
End If

If BindInternal(LocalPort, LocalIP) Then
    m_enmState = sckOpen: Debug.Print "STATE: sckOpen"
End If
End Sub

'This function binds a socket to a local port and IP.
'Retunrs TRUE if it has success.
Private Function BindInternal(Optional ByVal varLocalPort As Variant, Optional ByVal varLocalIP As Variant) As Boolean
If m_enmState = sckOpen Then
    BindInternal = True
    Exit Function
End If

Dim lngLocalPortInternal As Long
Dim strLocalHostInternal As String
Dim strIP As String
Dim lngAddressInternal As Long
Dim lngResult As Long
Dim lngErrorCode As Long

BindInternal = False

'Check if varLocalPort is a number between 0 and 65535
If Not IsMissing(varLocalPort) Then
    
    If IsNumeric(varLocalPort) Then
        If varLocalPort < 0 Or varLocalPort > 65535 Then
            BindInternal = False
            Err.Raise sckInvalidArg, "CSocketMaster.BindInternal", "The argument passed to a function was not in the correct format or in the specified range."
        Else
            lngLocalPortInternal = CLng(varLocalPort)
        End If
    Else
        BindInternal = False
        Err.Raise sckUnsupported, "CSocketMaster.BindInternal", "Unsupported variant type."
    End If
    
Else
    
    lngLocalPortInternal = m_lngLocalPort
    
End If

If Not IsMissing(varLocalIP) Then
    If varLocalIP <> vbNullString Then
        strLocalHostInternal = CStr(varLocalIP)
    Else
        strLocalHostInternal = ""
    End If
Else
    strLocalHostInternal = ""
End If

'get a 32 bits long IP
lngAddressInternal = ResolveIfHostnameSync(strLocalHostInternal, strIP, lngResult)

If lngResult <> 0 Then
    Err.Raise sckInvalidArg, "CSocketMaster.BindInternal", "Invalid argument"
End If

'create a socket if there isn't one yet
If Not SocketExists Then Exit Function

Dim udtSockAddr As sockaddr_in

With udtSockAddr
    .sin_addr = lngAddressInternal
    .sin_family = AF_INET
    .sin_port = api_htons(modSocketMaster.UnsignedToInteger(lngLocalPortInternal))
End With

'bind the socket
lngResult = api_bind(m_lngSocketHandle, udtSockAddr, LenB(udtSockAddr))

If lngResult = SOCKET_ERROR Then

    lngErrorCode = Err.LastDllError
    Err.Raise lngErrorCode, "CSocketMaster.BindInternal", GetErrorDescription(lngErrorCode)
    
Else

    If lngLocalPortInternal <> 0 Then
    
        Debug.Print "OK Bind HOST: " & strLocalHostInternal & " PORT: " & lngLocalPortInternal
        m_lngLocalPort = lngLocalPortInternal
        
    Else
        lngResult = GetLocalPort(m_lngSocketHandle)
        
        If lngResult = SOCKET_ERROR Then
            lngErrorCode = Err.LastDllError
            Err.Raise lngErrorCode, "CSocketMaster.BindInternal", GetErrorDescription(lngErrorCode)
        Else
            Debug.Print "OK Bind HOST: " & strLocalHostInternal & " PORT: " & lngResult
            m_lngLocalPortBind = lngResult
        End If
        
    End If
    
    BindInternal = True
End If
End Function

'Allocate some memory for HOSTEN structure and returns
'a pointer to this buffer if no error occurs.
'Returns 0 if it fails.
Private Function AllocateMemory() As Long
m_lngMemoryHandle = api_GlobalAlloc(GMEM_FIXED, MAXGETHOSTSTRUCT)

If m_lngMemoryHandle <> 0 Then
    m_lngMemoryPointer = api_GlobalLock(m_lngMemoryHandle)
    
    If m_lngMemoryPointer <> 0 Then
        api_GlobalUnlock (m_lngMemoryHandle)
        AllocateMemory = m_lngMemoryPointer
    Else
        api_GlobalFree (m_lngMemoryHandle)
        AllocateMemory = m_lngMemoryPointer '0
    End If

Else
    AllocateMemory = m_lngMemoryHandle '0
End If
End Function

'Free memory allocated by AllocateMemory
Private Sub FreeMemory()
If m_lngMemoryHandle <> 0 Then
    m_lngMemoryPointer = 0
    api_GlobalFree m_lngMemoryHandle
    m_lngMemoryHandle = 0
    Debug.Print "OK Freed resolution memory"
End If
End Sub

Private Function GetLocalHostName() As String
Dim strHostNameBuf As String * LOCAL_HOST_BUFF
Dim lngResult As Long

lngResult = api_gethostname(strHostNameBuf, LOCAL_HOST_BUFF)

If lngResult = SOCKET_ERROR Then
    GetLocalHostName = vbNullString
    Dim lngErrorCode As Long
    lngErrorCode = Err.LastDllError
    Err.Raise lngErrorCode, "CSocketMaster.GetLocalHostName", GetErrorDescription(lngErrorCode)
Else
    GetLocalHostName = Left(strHostNameBuf, InStr(1, strHostNameBuf, vbNullChar) - 1)
End If
End Function

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
狠狠色狠狠色综合| 91精品国产综合久久久久| 在线观看日韩av先锋影音电影院| 欧美久久久久久蜜桃| 国产精品亲子伦对白| 天堂精品中文字幕在线| av午夜一区麻豆| ww亚洲ww在线观看国产| 婷婷中文字幕一区三区| 91丝袜呻吟高潮美腿白嫩在线观看| 91麻豆精品国产91久久久久久| 国产精品福利一区二区| 国内成+人亚洲+欧美+综合在线| av在线播放成人| 久久久久久久综合色一本| 日本欧美一区二区| 在线观看一区日韩| 亚洲色图第一区| 国产精品一区二区久久精品爱涩| 欧美日韩三级在线| 亚洲精品视频在线观看网站| 成人激情综合网站| 2020国产精品自拍| 激情成人午夜视频| 欧美成人猛片aaaaaaa| 欧美aaaaaa午夜精品| 欧美高清dvd| 亚洲第一电影网| 在线亚洲+欧美+日本专区| 最新国产精品久久精品| 成人av综合一区| 国产精品电影一区二区三区| 成人国产视频在线观看| 国产精品毛片久久久久久久| 国产成人午夜99999| 久久日一线二线三线suv| 精品一二三四区| 欧美成人精品3d动漫h| 青娱乐精品视频在线| 精品日韩欧美在线| 国产精品综合二区| 国产欧美日产一区| 9i在线看片成人免费| 国产精品久久久一区麻豆最新章节| 成人小视频免费观看| 日韩毛片精品高清免费| 一本一道综合狠狠老| 一区二区三区在线视频观看| 欧美在线观看视频在线| 天天综合日日夜夜精品| 欧美高清一级片在线| 久久国产精品一区二区| 久久综合久久综合久久| 成人免费的视频| 亚洲女人的天堂| 91精品国产综合久久精品app| 麻豆精品一区二区综合av| www一区二区| 99久久伊人久久99| 亚洲成在线观看| 精品国产免费一区二区三区四区| 国产成人午夜片在线观看高清观看| 国产精品不卡在线| 91.com视频| 成人美女在线观看| 日韩国产精品久久| 国产欧美一区二区精品性| 95精品视频在线| 免费在线观看一区| 亚洲欧洲日产国产综合网| 欧美日韩久久一区二区| 国产精品亚洲成人| 午夜视黄欧洲亚洲| 欧美激情一区二区在线| 欧美精品777| 99精品国产91久久久久久 | 丝袜诱惑亚洲看片| 久久综合九色综合欧美就去吻 | 亚洲国产精品99久久久久久久久| 91蜜桃网址入口| 蜜桃视频在线观看一区二区| 日韩毛片一二三区| 久久精品亚洲一区二区三区浴池| 色噜噜狠狠成人中文综合| 国模冰冰炮一区二区| 亚洲一区二区三区免费视频| 中文字幕久久午夜不卡| 日韩欧美一区二区在线视频| 色av一区二区| 成人18视频在线播放| 国产一区二区中文字幕| 亚洲成人动漫av| ...中文天堂在线一区| 久久久久久9999| 欧美一二三在线| 欧美日韩精品一区二区三区四区| 99久久精品一区| 国产激情偷乱视频一区二区三区| 蜜桃视频在线一区| 日本女人一区二区三区| 日本成人中文字幕| 91精品国产综合久久精品性色| 久久久亚洲欧洲日产国码αv| 日本精品一区二区三区高清 | 亚洲午夜久久久久久久久久久| 久久精品这里都是精品| 日韩午夜激情电影| 欧美日韩三级一区| 欧美午夜精品理论片a级按摩| 成人伦理片在线| 国产精品亚洲成人| 国产一区二区三区精品视频| 看片网站欧美日韩| 日韩av电影免费观看高清完整版| 亚洲国产综合人成综合网站| 亚洲伦理在线免费看| 中文字幕中文字幕一区二区 | 欧美一区二区在线观看| 8v天堂国产在线一区二区| 欧美在线影院一区二区| 日本高清不卡一区| 在线观看日韩高清av| 欧美色图片你懂的| 欧美久久久一区| 91精品国产手机| 精品久久久久久久久久久久久久久久久 | 亚洲国产综合人成综合网站| 亚洲一区二区三区四区在线观看 | 91亚洲大成网污www| 成人黄色a**站在线观看| 成人激情电影免费在线观看| 成人av免费在线| 一本到不卡精品视频在线观看| 一本久道久久综合中文字幕| 色综合久久天天| 欧美亚洲综合一区| 日韩精品中午字幕| 欧美激情一区二区三区四区| 亚洲人成伊人成综合网小说| 亚洲va天堂va国产va久| 久久国产生活片100| 国产成人av电影免费在线观看| 91色.com| 日韩欧美一级特黄在线播放| 国产精品视频一二三区| 一个色在线综合| 日本va欧美va精品发布| 国模大尺度一区二区三区| 972aa.com艺术欧美| 欧美一区二区在线播放| 国产无人区一区二区三区| 亚洲免费观看高清完整| 蜜臀久久99精品久久久久久9 | 91麻豆精品在线观看| 欧美视频在线播放| 久久久国产一区二区三区四区小说 | 99视频有精品| 91麻豆精品国产91久久久资源速度 | 欧美一级日韩不卡播放免费| 久久精品免费在线观看| 亚洲精品成人天堂一二三| 久久99国产精品久久99| 色香色香欲天天天影视综合网 | 在线免费观看日本欧美| 欧美精品一区二区三区一线天视频 | 日韩视频在线你懂得| 国产精品久久久久久久久图文区 | 欧美日韩一区二区在线观看| 久久在线观看免费| 亚洲午夜国产一区99re久久| 国产精品99久久久久久久vr| 欧美日韩免费观看一区二区三区| 国产视频不卡一区| 人人狠狠综合久久亚洲| 在线区一区二视频| 中文字幕一区二区三| 国内精品伊人久久久久av一坑| 一本大道久久a久久综合婷婷| www激情久久| 久久99精品国产91久久来源| 欧美羞羞免费网站| 亚洲免费av在线| www.爱久久.com| 国产欧美日韩一区二区三区在线观看| 性做久久久久久久免费看| 91麻豆国产福利精品| 国产精品网曝门| 国产一区二区三区在线观看精品 | 国产欧美一区二区三区沐欲| 激情综合五月天| 欧美精品久久久久久久多人混战 | 国产网站一区二区三区| 黑人精品欧美一区二区蜜桃 | 久久精品99国产国产精| 制服视频三区第一页精品| 亚洲国产综合91精品麻豆| 91麻豆国产自产在线观看| 亚洲乱码精品一二三四区日韩在线| 成人黄页毛片网站| 国产精品美女久久久久高潮|