我的服务端程序
Private Sub Command1_Click()
With CommonDialog1
.CancelError = True
.DialogTitle = "选择您要传送的文件"
.Filter = "All Files (*.*)|*.*"
.ShowOpen
End With
Text1 = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
sckserver(0).Bind sckserver(0).LocalPort
sckserver(0).Listen
'Command2.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If sckserver(0).State <> sckClosed Then
sckserver(0).Close
End If
End Sub
Private Sub sckserver_connectionrequest(index As Integer, ByVal requestid As Long)
Dim sip As String
Dim I As Integer
Dim mybyte As String
Dim allbyte As String
'Dim bytenum As String * 3
sip = sckserver(0).RemoteHostIP
I = 1
Do While I <= sckserver.ubound
If sckserver(I).RemoteHostIP = sip Then
sckserver(I).Accept requestid
Exit Sub
End If
I = I + 1
Loop
Load sckserver(I)
sckserver(I).Accept requestid
Command1.Enabled = False
Open CommonDialog1.FileName For Input As #1
'bytenum = LOF(1)
'bytenum = "f" + bytenum
'sckserver(I).SendData "f" & bytenum
While Not EOF(1)
Line Input #1, mybyte
If mybyte = "" Then allbyte = allbyte + vbCrLf
allbyte = allbyte + mybyte
Wend
Close #1
sckserver(I).SendData allbyte
End Sub
客户端
Private Sub Command1_Click()
Dim ipaddr As String
ipaddr = Text1
Winsock1.Connect ipaddr, Winsock1.RemotePort
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sdata As String
Winsock1.GetData sdata, vbString
运行后在客户端接受数据时产生40006错误,这是为什么啊????
我把东西传上来,你们看看有什么地方错了,谢谢了
[此贴子已经被作者于2006-2-11 13:20:29编辑过]