# Re: 我重新post, 发现了新的问题了..

Posted by Buier on October 25, 1999 at 04:38:28:

In Reply to: 你程式有漏给吧! posted by 小吴 on October 24, 1999 at 22:23:57:

: 你 POST 上来的程式漏了最重要的 DataArrival 事件，这样谁能帮你找问题呀!?
真的吗,sorry...我重新post 一次..
其中sleep 放在module中,我又有新的问题了..以下程
式应该可以作拷贝的动作,虽然很慢..一次一位元的传
,但是有一个很奇怪的地方.如果送资料的时候没有加上
延迟(sleep)的话,那接收到的资料就会乱七八遭的..??
还有在tcp/ip的传输模式下以前记得老师说过好像一次
最大可以传 1518byte? 谢谢大家肯花时间帮忙喽..^^

Dim Arry(10000) As Byte, Cnt As Double
Private Sub Command1_Click()
Dim T As Byte, T1 As Double
Open "C:\1.htm" For Binary Access Read As #1
MsgBox FileLen("C:\1.txt")
For T1 = 1 To FileLen("C:\1.htm")
Get #1, , T
'MsgBox "Server:" + Str$(T)
sckSer.SendData T
Module1.Sleep (300)
A = DoEvents()
Next
Close
MsgBox "Send Over"
End Sub

Private Sub Command2_Click()
sckCli.Connect Text1.Text
End Sub

Private Sub Command3_Click()
sckCli.Close
sckSer.Close
sckSer.Listen
Form1.Caption = "No Connected"
End Sub

Private Sub Command4_Click()
Dim T1 As Double
Open "C:\2.htm" For Binary Access Write As #2
For T1 = 0 To Cnt - 1
Put #2, , Arry(T1)
A = DoEvents()
Next
Close #2
MsgBox "Saved"
End Sub

Private Sub Form_Load()
sckSer.Listen
End Sub

Private Sub sckCli_Connect()
If sckCli.State = 7 Then Form1.Caption = "Connected"
End Sub

Private Sub sckCli_DataArrival(ByVal bytesTotal As Long)
Dim T As Byte
sckCli.GetData T, vbByte
Arry(Cnt) = T
Cnt = Cnt + 1
End Sub

Private Sub sckSer_ConnectionRequest(ByVal requestID As Long)
sckSer.Close
sckSer.Accept requestID
End Sub

- VB心得交流网

Follow Ups: