R
Rich
I am writing two programs that are part of a Bulletin board system.
The program works right, but when information is downloaded, the server
program refuses to send more than 9 Kilobytes of data to the client.
How can this be fixed?
The code is:
Server (Running in a separate thread from UI):
H:
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Try
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.Unicode.GetString(bytes)
Dim responseString As String = TextBox1.Text
Dim sendBytes As [Byte]() = Encoding.Unicode.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
tcpClient.Close()
tcpListener.Stop()
Catch e As Exception
End Try
GoTo H
End Sub
Try
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(ip, port)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.Unicode.GetBytes(TextBox2.Text)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.Unicode.GetString(bytes)
Me.Close()
Else
If Not networkStream.CanRead Then
MsgBox("Data cannot be written.")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
MsgBox("Data cannot be read.")
tcpClient.Close()
End If
End If
End If
Catch ex As Exception
MsgBox("Error! Sever is not functioning!")
MsgBox(ex.ToString)
MsgBox(ex.Message)
End Try
Sorry about the sloppy coding. This is partially based on something i
found on Egghead cafe. If it matters, I am using a fast computer with
Windows XP Professional.
The program works right, but when information is downloaded, the server
program refuses to send more than 9 Kilobytes of data to the client.
How can this be fixed?
The code is:
Server (Running in a separate thread from UI):
H:
Const portNumber As Integer = 8000
Dim tcpListener As New TcpListener(portNumber)
tcpListener.Start()
Try
Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient()
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))
Dim clientdata As String = Encoding.Unicode.GetString(bytes)
Dim responseString As String = TextBox1.Text
Dim sendBytes As [Byte]() = Encoding.Unicode.GetBytes(responseString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
tcpClient.Close()
tcpListener.Stop()
Catch e As Exception
End Try
GoTo H
End Sub
Try
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(ip, port)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.Unicode.GetBytes(TextBox2.Text)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.Unicode.GetString(bytes)
Me.Close()
Else
If Not networkStream.CanRead Then
MsgBox("Data cannot be written.")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
MsgBox("Data cannot be read.")
tcpClient.Close()
End If
End If
End If
Catch ex As Exception
MsgBox("Error! Sever is not functioning!")
MsgBox(ex.ToString)
MsgBox(ex.Message)
End Try
Sorry about the sloppy coding. This is partially based on something i
found on Egghead cafe. If it matters, I am using a fast computer with
Windows XP Professional.