主题:winsock传输文件的问题
server端是这样写的:
Dim getlen As Long
Dim buffer() As Byte
Dim file As String
file = "E:\MySample\VB\WinSock\Multiple_FileTransport\Client\b.mp3"
Open file For Binary As #1
sckserver(Index).GetData buffer
getlen = getlen + UBound(buffer) + 1
Put #1, , buffer
Close #1
client端是这样的:
Dim FileArray() As Byte
Dim lnfile As Long
Dim srcpath As String
srcpath = "E:\MySample\VB\WinSock\Multiple_FileTransport\Client\a.mp3"
Text1.Text = FileLen(srcpath)
Open srcpath For Binary As #1
lnfile = FileLen(srcpath)
ReDim FileArray(lnfile)
Get #1, , FileArray
Close #1
sckconnect.SendData FileArray
实际中Client在接收文件时根本不知道Server发送文件的类型(如上面的a.mp3)
Dim getlen As Long
Dim buffer() As Byte
Dim file As String
file = "E:\MySample\VB\WinSock\Multiple_FileTransport\Client\b.mp3"
Open file For Binary As #1
sckserver(Index).GetData buffer
getlen = getlen + UBound(buffer) + 1
Put #1, , buffer
Close #1
client端是这样的:
Dim FileArray() As Byte
Dim lnfile As Long
Dim srcpath As String
srcpath = "E:\MySample\VB\WinSock\Multiple_FileTransport\Client\a.mp3"
Text1.Text = FileLen(srcpath)
Open srcpath For Binary As #1
lnfile = FileLen(srcpath)
ReDim FileArray(lnfile)
Get #1, , FileArray
Close #1
sckconnect.SendData FileArray
实际中Client在接收文件时根本不知道Server发送文件的类型(如上面的a.mp3)