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

📄 服务器.frm

📁 VB局域网聊天软件
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1 
   Caption         =   "服务器"
   ClientHeight    =   3150
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5085
   LinkTopic       =   "Form1"
   ScaleHeight     =   3150
   ScaleWidth      =   5085
   StartUpPosition =   3  '窗口缺省
   Begin MSWinsockLib.Winsock Winsock1 
      Index           =   0
      Left            =   2280
      Top             =   1320
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   960
      TabIndex        =   0
      Text            =   "0"
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "在线人数"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   360
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Gac() As Boolean
Dim Socknumber As Integer
Private Sub Form_Load()
   Winsock1(0).LocalPort = 1600
   Winsock1(0).Listen
   Socknumber = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Winsock1(0).Close
End Sub

Private Sub Winsock1_Close(Index As Integer)
   Winsock1(Index).Close
   Unload Winsock1(Index)
   Gac(Index) = False
   Text3.Text = Int(Text3.Text) - 1
End Sub

Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
   Socknumber = Socknumber + 1
   
   Load Winsock1(Socknumber)
   Winsock1(Socknumber).Accept requestID
   ReDim Preserve Gac(Socknumber)
   Gac(Socknumber) = True
   Text3.Text = Int(Text3.Text) + 1
End Sub

Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
   Dim c As String
   Winsock1(Index).GetData c, vbString
   Dim i As Integer
   For i = 1 To UBound(Gac)
     If Not i = Index Then
      If Gac(i) Then
         Winsock1(i).SendData c
       DoEvents
      End If
     End If
   Next i
   
   
End Sub

⌨️ 快捷键说明

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