如果发送缓冲是TxBuf(0 to N),发送长度是Total(total < N) 发送前 dim Buf() as byte dim sData as variant redim Buf(0 to Total - 1) for i = 0 to total - 1 buf(i) = txbuf(i) next i sdata = buf winsock.senddata sdata
Private Sub Command1_Click() Dim a(3) As Byte Dim ss As String * 4 ss = "ABCD" Call CopyMemory(a(0), ss, 4) Winsock1.SendData a End Sub
Client: dim ByteArray() as byte openfile FileName, ByteArray()'读取文件函数(自行编写) tcpClient.SendData ByteArray()'发送Server: tcpServer.GetData ByteArray(), vbByte'接收 writefile FileName,Bytearray()'写文件函数(自行编写)
发送前
dim Buf() as byte
dim sData as variant
redim Buf(0 to Total - 1)
for i = 0 to total - 1
buf(i) = txbuf(i)
next i
sdata = buf
winsock.senddata sdata
Dim a(3) As Byte
Dim ss As String * 4
ss = "ABCD"
Call CopyMemory(a(0), ss, 4)
Winsock1.SendData a
End Sub
dim ByteArray() as byte
openfile FileName, ByteArray()'读取文件函数(自行编写)
tcpClient.SendData ByteArray()'发送Server:
tcpServer.GetData ByteArray(), vbByte'接收
writefile FileName,Bytearray()'写文件函数(自行编写)