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

📄 server.frm

📁 一个VB做的语音系统控件
💻 FRM
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form server 
   Caption         =   "服务管理器"
   ClientHeight    =   3900
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3600
   Icon            =   "server.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3900
   ScaleWidth      =   3600
   StartUpPosition =   2  '屏幕中心
   Begin VB.ListBox List1 
      Height          =   1320
      Left            =   0
      TabIndex        =   10
      Top             =   2280
      Width           =   3615
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      Left            =   1320
      TabIndex        =   6
      Text            =   "701"
      Top             =   420
      Width           =   2175
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   1320
      TabIndex        =   4
      Top             =   60
      Width           =   2175
   End
   Begin VB.CommandButton pause 
      Height          =   300
      Left            =   960
      Picture         =   "server.frx":014A
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   1400
      Width           =   400
   End
   Begin VB.CommandButton stopnow 
      Height          =   300
      Left            =   960
      Picture         =   "server.frx":069E
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   1880
      Width           =   400
   End
   Begin VB.CommandButton start 
      Enabled         =   0   'False
      Height          =   300
      Left            =   960
      Picture         =   "server.frx":0BF2
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   960
      Width           =   400
   End
   Begin MSWinsockLib.Winsock sckServer 
      Index           =   0
      Left            =   840
      Top             =   1200
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin MSWinsockLib.Winsock sckListen 
      Left            =   840
      Top             =   840
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "结束"
      Height          =   180
      Left            =   1560
      TabIndex        =   9
      Top             =   1995
      Width           =   360
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "暂停"
      Height          =   180
      Left            =   1560
      TabIndex        =   8
      Top             =   1515
      Width           =   360
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "开始/继续"
      Height          =   180
      Left            =   1560
      TabIndex        =   7
      Top             =   1080
      Width           =   810
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "端口(&P):"
      Height          =   180
      Left            =   120
      TabIndex        =   5
      Top             =   480
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "服务器(&V):"
      Height          =   180
      Left            =   120
      TabIndex        =   3
      Top             =   120
      Width           =   900
   End
End
Attribute VB_Name = "server"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private local_port As Integer

Private Sub Form_Load()
   local_port = 701
   Combo1.Text = sckListen.LocalIP
   Dim i As Integer
   sckListen.LocalPort = local_port
   sckListen.Listen
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  If MsgBox("[确定]:关闭服务![取消]:最小化窗口!", vbOKCancel, "提示") = vbOK Then
     Unload Me
  Else
     Cancel = -1
     Me.WindowState = 1
  End If
End Sub

Private Sub Form_Resize()
   On Error Resume Next
   lstReceive.Width = Me.Width - 100
   lstReceive.Height = Me.Height - 100
End Sub



Private Sub pause_Click()
  sckListen.Close
  pause.Enabled = False
  start.Enabled = True
  stopnow.Enabled = True
End Sub

Private Sub sckListen_ConnectionRequest(ByVal requestID As Long)
  Dim i As Integer
  '决定由哪一Winsock接受请求
  For i = 0 To sckServer.Count - 1
   If sckServer(i).State = 0 Then
    sckServer(i).Accept requestID
    List1.AddItem CStr(sckServer(i).RemoteHostIP) + CStr(sckServer(i).RemotePort)
    Exit Sub
    Exit For
   End If
  Next i
  Load sckServer(sckServer.Count)
  sckServer(sckServer.Count - 1).Accept requestID
      List1.AddItem CStr(sckServer(i).RemoteHostIP) + CStr(sckServer(i).RemotePort)
End Sub

Private Sub sckListen_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  sckListen.Close
  sckListen.LocalPort = local_port
  sckListen.Listen

End Sub

Private Sub sckServer_Close(Index As Integer)
  sckServer(Index).Close
End Sub

Private Sub sckServer_DataArrival(Index As Integer, ByVal bytesTotal As Long)
  Dim s As Variant
  Dim i As Integer
  sckServer(Index).GetData s
      For i = 0 To sckServer.Count - 1 Step 1
        If sckServer(i).State <> sckClosed And Index <> i Then
             sckServer(i).SendData s
             DoEvents
        End If
      Next i
End Sub


Private Sub sckServer_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
  sckServer(Index).Close
End Sub


Private Sub start_Click()
  sckListen.Close
  sckListen.Listen
  start.Enabled = False
  pause.Enabled = True
  stopnow.Enabled = True
End Sub

Private Sub stopnow_Click()
  sckListen.Close
  For i = 0 To sckServer.Count - 1
     sckServer(i).Close
  Next i
  stopnow.Enabled = False
  pause.Enabled = False
  start.Enabled = True
End Sub

⌨️ 快捷键说明

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