0
我想通過使用Socket的vb.net中的套接字傳輸文件。如何通過vb.net中的Socket傳輸文件和WCF
我想通過使用Socket的vb.net中的套接字傳輸文件。如何通過vb.net中的Socket傳輸文件和WCF
服務器端:
Do
Try
message = reader.ReadString()
If message = "ATTACHMENT" Then
writer.Write("")
Dim num = reader.ReadInt64
Dim BR As BinaryReader
Dim FS As NetworkStream
FS = output
Dim fulname As String = reader.ReadString
BR = New BinaryReader(FS)
Dim buffer(num) As Byte
buffer = BR.ReadBytes(num)
Dim BW As BinaryWriter
Dim FSOut As FileStream
FSOut = New FileStream(fulname, FileMode.Create, FileAccess.Write)
BW = New BinaryWriter(FSOut)
BW.Write(buffer)
message = ""
BW.Close()
writer.Write("CLIENT >> ATTACHMENT RECIEVED")
End If
Catch ex As Exception
System.Environment.Exit(System.Environment.ExitCode)
End Try
Loop While message <> "SERVER >> EXIT"
客戶端:
Do
Try
messageRecieved = reader.ReadString()
If messageRecieved = "ATTACHMENT" Then
writer.Write("")
Dim num = reader.ReadInt64
Dim BR As BinaryReader
Dim FS As NetworkStream
FS = socketStream
Dim fulname As String = reader.ReadString
BR = New BinaryReader(FS)
Dim buffer(num) As Byte
buffer = BR.ReadBytes(num)
Dim BW As BinaryWriter
Dim FSOut As FileStream
FSOut = New FileStream(fulname, FileMode.Create, FileAccess.Write)
BW = New BinaryWriter(FSOut)
BW.Write(buffer)
messageRecieved = ""
BW.Close()
writer.Write("SERVER >> ATTACHMENT RECIEVED")
End If
Catch ex As Exception
Exit Do
End Try
Loop While messageRecieved <> "CLIENT >> EXIT" And connection.Connected
你的問題是沒有意義的。 –
好主意。現在,您是否嘗試搜索任何現有的響應? –
很高興知道 - 現在你有問題嗎? –