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

📄 frmtcp.frm

📁 一个很好的TCP和UDP端口控制的例子!稍加改动
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1 
   Caption         =   "TCP Client/Server"
   ClientHeight    =   6165
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9960
   LinkTopic       =   "Form1"
   ScaleHeight     =   6165
   ScaleWidth      =   9960
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer Timer1 
      Left            =   5880
      Top             =   5640
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "Exit"
      Height          =   375
      Left            =   7080
      TabIndex        =   3
      Top             =   5640
      Width           =   1575
   End
   Begin VB.Frame Frame3 
      Caption         =   "Winsock Information"
      Height          =   5295
      Left            =   5640
      TabIndex        =   2
      Top             =   120
      Width           =   4215
      Begin ComctlLib.ListView lstStates 
         Height          =   3735
         Left            =   120
         TabIndex        =   19
         Top             =   1440
         Width           =   3975
         _ExtentX        =   7011
         _ExtentY        =   6588
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   0   'False
         _Version        =   327682
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   3
         BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Socket"
            Object.Width           =   1940
         EndProperty
         BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   1
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "State"
            Object.Width           =   3069
         EndProperty
         BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
            SubItemIndex    =   2
            Key             =   ""
            Object.Tag             =   ""
            Text            =   "Port"
            Object.Width           =   2540
         EndProperty
      End
      Begin VB.Label Label8 
         Caption         =   "State Information:"
         Height          =   255
         Left            =   120
         TabIndex        =   24
         Top             =   1200
         Width           =   1575
      End
      Begin VB.Label lblLocalHostIP 
         Height          =   255
         Left            =   1680
         TabIndex        =   23
         Top             =   720
         Width           =   2175
      End
      Begin VB.Label lblLocalHostname 
         Height          =   255
         Left            =   1680
         TabIndex        =   22
         Top             =   360
         Width           =   2175
      End
      Begin VB.Label Label7 
         Caption         =   "Local Host Name:"
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   360
         Width           =   1290
      End
      Begin VB.Label Label6 
         Caption         =   "Local IP:"
         Height          =   255
         Left            =   885
         TabIndex        =   20
         Top             =   705
         Width           =   735
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "TCP Client"
      Height          =   2535
      Left            =   120
      TabIndex        =   1
      Top             =   3480
      Width           =   5295
      Begin VB.CommandButton cmdSendData 
         Caption         =   "Send Data"
         Height          =   375
         Left            =   3840
         TabIndex        =   14
         Top             =   1920
         Width           =   1335
      End
      Begin VB.CommandButton cmdDisconnect 
         Caption         =   "Disconnect"
         Height          =   375
         Left            =   3840
         TabIndex        =   13
         Top             =   720
         Width           =   1335
      End
      Begin VB.CommandButton cmdConnect 
         Caption         =   "Connect"
         Height          =   375
         Left            =   3840
         TabIndex        =   12
         Top             =   240
         Width           =   1335
      End
      Begin VB.TextBox txtSendData 
         Height          =   975
         Left            =   120
         MultiLine       =   -1  'True
         TabIndex        =   10
         Top             =   1440
         Width           =   3495
      End
      Begin VB.TextBox txtPort 
         Height          =   285
         Left            =   1200
         TabIndex        =   8
         Text            =   "5150"
         Top             =   720
         Width           =   1095
      End
      Begin VB.TextBox txtServerName 
         Height          =   285
         Left            =   1200
         TabIndex        =   6
         Text            =   "riven"
         Top             =   360
         Width           =   1935
      End
      Begin MSWinsockLib.Winsock sockClient 
         Left            =   4560
         Top             =   1200
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   393216
      End
      Begin VB.Label Label4 
         Caption         =   "Message:"
         Height          =   255
         Left            =   120
         TabIndex        =   11
         Top             =   1200
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "Remote Port:"
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   720
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "Server Name:"
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "TCP Server"
      Height          =   3135
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5295
      Begin VB.CommandButton cmdCloseListen 
         Caption         =   "Close Listen"
         Height          =   375
         Left            =   3960
         TabIndex        =   17
         Top             =   720
         Width           =   1215
      End
      Begin VB.CommandButton cmdListen 
         Caption         =   "Listen"
         Height          =   375
         Left            =   3960
         TabIndex        =   16
         Top             =   240
         Width           =   1215
      End
      Begin VB.ListBox lstMessages 
         Height          =   1620
         Left            =   120
         TabIndex        =   15
         Top             =   1200
         Width           =   5055
      End
      Begin VB.TextBox txtServerPort 
         Height          =   285
         Left            =   1080
         TabIndex        =   5
         Text            =   "5150"
         Top             =   360
         Width           =   1575
      End
      Begin MSWinsockLib.Winsock sockServer 
         Index           =   0
         Left            =   3120
         Top             =   360
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   393216
      End
      Begin VB.Label Label5 
         Caption         =   "Messages:"
         Height          =   255
         Left            =   120
         TabIndex        =   18
         Top             =   960
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "Port:"
         Height          =   255
         Left            =   600
         TabIndex        =   4
         Top             =   360
         Width           =   375
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' The index value of the last Winsock control dynamically loaded
' in the sockServer array
Private ServerIndex As Long

Private Sub cmdCloseListen_Click()
    Dim itemx As Object
    ' Close the server's listening socket. No more
    ' clients will be allowed to connect.
    '
    sockServer(0).Close

⌨️ 快捷键说明

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