TCP
VERSION 5.00 Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX" Begin VB.Form frmServer Caption = "frmServer" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" MaxButton = 0 'False ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.TextBox txtSendData Height = 1575 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 1 Text = "Form1.frx":0000 Top = 1560 Width = 4575 End Begin VB.TextBox txtoutput Height = 1455 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 0 Text = "Form1.frx":0006 Top = 0 Width = 4575 End Begin MSWinsockLib.Winsock Winsock1 Left = 4320 Top = 1320 _ExtentX = 741 _ExtentY = 741 _Version = 393216 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() ' Me.Winsock1.LocalPort = 1001 Me.Winsock1.Listen frmClient.Show End Sub Private Sub txtSendData_Change() ' Me.Winsock1.SendData Me.txtSendData.Text End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) ' If Me.Winsock1.State <> sckClosed Then Me.Winsock1.Close End If Me.Winsock1.Accept requestID End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ' Dim strData As String Me.Winsock1.GetData strData Me.txtoutput.Text = strData End Sub
VERSION 5.00 Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX" Begin VB.Form frmClient Caption = "frmClient" ClientHeight = 3660 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3660 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 375 Left = 3240 TabIndex = 2 Top = 3240 Width = 1215 End Begin VB.TextBox txtSendData Height = 1455 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 1 Text = "frmClient.frx":0000 Top = 1680 Width = 4575 End Begin VB.TextBox txtOutput Height = 1575 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 0 Text = "frmClient.frx":0006 Top = 0 Width = 4575 End Begin MSWinsockLib.Winsock Winsock1 Left = 0 Top = 3240 _ExtentX = 741 _ExtentY = 741 _Version = 393216 End End Attribute VB_Name = "frmClient" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() ' Me.Winsock1.Connect End Sub Private Sub Form_Load() ' Me.Winsock1.RemoteHost = Me.Winsock1.LocalHostName Me.Winsock1.RemotePort = 1001 End Sub Private Sub txtSendData_Change() ' Me.Winsock1.SendData Me.txtSendData.Text End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ' Dim strData As String Me.Winsock1.GetData strData Me.txtOutput.Text = strData End Sub
UDP
VERSION 5.00 Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX" Begin VB.Form FrmA Caption = "FrmA" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.TextBox txtsend Height = 1455 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 1 Text = "FrmA.frx":0000 Top = 1560 Width = 4575 End Begin VB.TextBox txtouput Height = 1455 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 0 Text = "FrmA.frx":0006 Top = 0 Width = 4575 End Begin MSWinsockLib.Winsock Winsock1 Left = 4200 Top = 2760 _ExtentX = 741 _ExtentY = 741 _Version = 393216 Protocol = 1 End End Attribute VB_Name = "FrmA" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() ' With Me.Winsock1 .RemoteHost = "PC2011021716zzc." .RemotePort = 1001 .Bind 1002 End With FrmB.Show End Sub Private Sub txtSend_Change() ' Me.Winsock1.SendData Me.txtSend.Text End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ' Dim strData As String Me.Winsock1.GetData strData Me.txtouput.Text = strData End Sub
VERSION 5.00 Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX" Begin VB.Form FrmB Caption = "FrmB" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin MSWinsockLib.Winsock Winsock1 Left = 4320 Top = 2760 _ExtentX = 741 _ExtentY = 741 _Version = 393216 Protocol = 1 End Begin VB.TextBox txtSend Height = 1335 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 1 Text = "FrmB.frx":0000 Top = 1800 Width = 4575 End Begin VB.TextBox txtOutput Height = 1695 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 0 Text = "FrmB.frx":0006 Top = 0 Width = 4575 End End Attribute VB_Name = "FrmB" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Form_Load() ' With Me.Winsock1 .RemoteHost = "PC2011021716zzc." .RemotePort = 1002 .Bind 1001 End With End Sub Private Sub txtSend_Change() ' Me.Winsock1.SendData Me.txtSend.Text End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) ' Dim strData As String Me.Winsock1.GetData strData Me.txtOutput.Text = strData End Sub