tommyready
Member
- Joined
- Jul 1, 2009
- Messages
- 23
- Programming Experience
- 3-5
I'm trying to write a simple server console app that logs user connections once a connection is established. I have the core part done but when I'm doing a console.write some how a huge amount of blank lines gets added in between the events.
the point where it writes: Console.WriteLine("Connection From: " + Trim(clientdata)) at least 10 to 15 blank lines gets inserted before Console.WriteLine("exit")
The only client data coming over is the clients ip address.
Anyone see a problem?
VB.NET:
Const portNumber As Integer = 8000
Dim LocalAddr As IPAddress = IPAddress.Parse("127.0.0.1")
Dim tcpListener As New Net.Sockets.TcpListener(LocalAddr, portNumber)
tcpListener.Start()
Console.WriteLine("Server Started...")
Try
'Accept the pending client connection and return
'a TcpClient initialized for communication.
Dim tcpClient As Sockets.TcpClient = tcpListener.AcceptTcpClient()
Console.WriteLine("Connection accepted.")
' Get the stream
Dim networkStream As Sockets.NetworkStream = tcpClient.GetStream()
' Read the stream into a byte array
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Return the data received from the client to the console.
Dim clientdata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine("Connection From: " + Trim(clientdata))
'tcpClient.Close()
'tcpListener.Stop()
Console.WriteLine("exit")
Console.ReadLine()
Catch e As Exception
Console.WriteLine(e.ToString())
Console.ReadLine()
End Try
the point where it writes: Console.WriteLine("Connection From: " + Trim(clientdata)) at least 10 to 15 blank lines gets inserted before Console.WriteLine("exit")
The only client data coming over is the clients ip address.
Anyone see a problem?