本文介绍了如何停止听winsock?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Class Form1
Private Sub AxWinsock1_ConnectionRequest(ByVal sender As System.Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent) Handles AxWinsock1.ConnectionRequest
AxWinsock1.Close()
AxWinsock1.Accept(e.requestID)
End Sub
Private Sub btnListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListen.Click
Try
AxWinsock1.LocalPort = txtPort.Text
AxWinsock1.Listen()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock1.DataArrival
Try
Dim data As String = ""
AxWinsock1.GetData(data)
TextBox1.Text &= vbNewLine & data.ToString
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub AxWinsock1_Error(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ErrorEvent) Handles AxWinsock1.Error
MsgBox(Err.Description)
AxWinsock1.Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Try
TextBox1.SelectionStart = TextBox1.Text.Length - 1
TextBox1.ScrollToCaret()
Catch ex As Exception
End Try
End Sub
End Class
推荐答案
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Try
AxWinsock1.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
这篇关于如何停止听winsock?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!