📄 frmwsk_svr.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmWSK
Caption = "Form1"
ClientHeight = 2325
ClientLeft = 2730
ClientTop = 3555
ClientWidth = 2700
LinkTopic = "Form1"
ScaleHeight = 2325
ScaleWidth = 2700
Begin VB.TextBox Text1
Height = 495
Left = 840
TabIndex = 0
Text = "Text1"
Top = 360
Width = 1215
End
Begin MSWinsockLib.Winsock tcpServer
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
End
Attribute VB_Name = "frmWSK"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
tcpServer.LocalPort = Port
tcpServer.Listen
bInconnection = False
Status "Listening.... (Not Connected)"
End Sub
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim Command As String
Dim NewArrival As String
Dim data As String
Dim FileSize As String
Dim filen As String
Static DataCnt As Long
Dim pk As String
tcpServer.GetData NewArrival$, vbString
If NewArrival$ = "NextChunk" Then
NextChunk = True
Exit Sub
End If
Command = Split(NewArrival$, ",")(0)
Select Case Command$
Case "OpenFile"
Dim Fname As String
data$ = Split(NewArrival$, ",")(1)
FileSize$ = Split(NewArrival$, ",")(2)
frmServer.ProgressBar1.Max = CLng(FileSize$)
Fname$ = App.Path & "\" & data$
Text1.Text = Fname
Open Fname$ For Binary As #1
Status "File opened.... " & data$
Status "Recieving Data... "
Case "CloseFile"
Close #1
Status "File Transfer complete..."
Pause 3000
Status "Listening... (Connected)"
Case Else
Put #1, , NewArrival$
SendData "NextChunk"
frmServer.ProgressBar1.Value = Seek(1) - 1
End Select
End Sub
Private Sub tcpServer_Close()
If tcpServer.State <> sckClosed Then tcpServer.Close
Form_Load
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
On Error GoTo IDERROR
If tcpServer.State <> sckClosed Then tcpServer.Close
tcpServer.Accept requestID
bInconnection = True
Status "Listening... Connected."
SendData "Accepted,"
Exit Sub
IDERROR:
MsgBox Err.Description, vbCritical
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -