⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.frm

📁 局域网聊天的开始,winscok,适宜初学都学习通信类开发
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmServer 
   Caption         =   "TCP Server"
   ClientHeight    =   5220
   ClientLeft      =   3990
   ClientTop       =   3585
   ClientWidth     =   6525
   LinkTopic       =   "Form1"
   ScaleHeight     =   5220
   ScaleWidth      =   6525
   Begin VB.TextBox txtOutput 
      Height          =   495
      Left            =   2640
      TabIndex        =   1
      Top             =   1200
      Width           =   1215
   End
   Begin VB.TextBox txtSendData 
      Height          =   495
      Left            =   2640
      TabIndex        =   0
      Top             =   480
      Width           =   1215
   End
   Begin MSWinsockLib.Winsock tcpServer 
      Left            =   5640
      Top             =   4440
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Label Label2 
      Caption         =   "接收到的"
      Height          =   495
      Left            =   1200
      TabIndex        =   3
      Top             =   1200
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "输入你的发送"
      Height          =   495
      Left            =   1080
      TabIndex        =   2
      Top             =   480
      Width           =   1215
   End
End
Attribute VB_Name = "frmServer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()

' Set the LocalPort property to an integer.
' Then invoke the Listen method.
tcpServer.LocalPort = 1001
tcpServer.Listen
frmClient.Show ' Show the client form.

End Sub

Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)

' Check if the control’s State is closed. If not,
'close the connection before accepting the new connection.
If tcpServer.State <> sckClosed Then tcpServer.Close
' Accept the request with the requestID parameter.
tcpServer.Accept requestID

End Sub

Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)

' Declare a variable for the incoming data.
' Invoke the GetData method and set the Text
' property of a TextBox named txtOutput to
' the data.
Dim strData As String
tcpServer.GetData strData
txtOutput.Text = strData

End Sub

Private Sub txtSendData_Change()
' The TextBox control named txtSendData
' contains the data to be sent. Whenever the user
' types into the textbox, the string is sent
' using the SendData method.
tcpServer.SendData txtSendData.Text

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -