Hi,
I'm making an IRC Client in VB.Net (2003). I'm trying to incorporate a DCC (Direct Client-To-Client) Get, but I'm having problems.
It only downloads the first kilobyte of information. I tried unsuccesfully using a BufferedStream.
Here's most of my code:
Basically, the problem is that it downloads a packet of data and stops. This is odd because I used almost the exact same code for the actual IRC part and it works great. (I also tried using dSR.Readtoend) and it also just gives me a packet of data).
Thank you in advance.
I'm making an IRC Client in VB.Net (2003). I'm trying to incorporate a DCC (Direct Client-To-Client) Get, but I'm having problems.
It only downloads the first kilobyte of information. I tried unsuccesfully using a BufferedStream.
Here's most of my code:
Visual Basic:
'TO CONNECT
DLipEndPt = New IPEndPoint(ipAddress, port)
'connect
txtStatus.Text &= "Connecting, please wait..." & vbCrLf
dSock = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) 'make a tcp socket
dSock.Connect(DLipEndPt)
netStr = New NetworkStream(dSock, True)
dSR = New StreamReader(netStr)
dSW = New StreamWriter(netStr)
Application.DoEvents()
timerGetStr.Enabled = True
'THE TIMER (set to 100)
Try
If txtStatus.Text.ToLower.IndexOf("receiving file") = -1 Then
' does only the first time
dSW.WriteLine("DCC GET " & nickName & " " & filename)
dSW.Flush()
txtStatus.Text &= "Sent acknowledgement..." & vbCrLf
'the acknowledgement is in accordance to the RFC guide
'to the IRC protocol
netStr = New NetworkStream(dSock)
End If
Application.DoEvents()
If txtStatus.Text.ToLower.IndexOf("receiving file...") = -1 And txtStatus.Text.ToLower.IndexOf("finished") = -1 _
Then txtStatus.Text &= "Receiving file..." & vbCrLf
If netStr.DataAvailable Then
Dim bytes(1024) As [Byte]
Dim data As [String] = Nothing
Dim i As Int32 = netStr.Read(bytes, 0, bytes.Length)
If i <> 0 Then
' Translate data bytes to a ASCII string.
'If Not serverWindow Then Console.Write("timer is working in channel window")
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
fSW = New StreamWriter(saveFileTo, True)
fSW.Write([String].Format("{0}", data))
fSW.Close()
wroteToFile = True
Application.DoEvents()
End If
ElseIf netStr.DataAvailable = False And wroteToFile Then
If txtStatus.Text.ToLower.IndexOf("finished") = -1 Then
txtStatus.Text &= "Finished downloading..."
btnOpenFile.Enabled = True
btnClose.Text = "Close"
Beep()
Application.DoEvents()
End If
End If
Catch ex As Exception
errorMsg(ex)
txtStatus.Text &= "An error has occurred..." & vbCrLf
End Try
Basically, the problem is that it downloads a packet of data and stops. This is odd because I used almost the exact same code for the actual IRC part and it works great. (I also tried using dSR.Readtoend) and it also just gives me a packet of data).
Thank you in advance.