I'm trying to make a client to a text based game. I've asked the question before, but now I've got a little bit more to work with. What I need is some help with it. I'll show the code first. Code for my 'tcpListener' which I've actually added to my overall project as a Console Application - Module1
Imports System.Net.Sockets
Imports System.Text
Module Module1
Sub Main()
Dim tcpListener As New TcpListener(6100)
Dim requestCount As Integer
Dim clientSocket As TcpClient
tcpListener.Start()
msg("Server Started")
clientSocket = tcpListener.AcceptTcpClient()
msg("Accept connection from client")
requestCount = 0
While (True)
Try
requestCount = requestCount + 1
Dim networkStream As NetworkStream = \_
clientSocket.GetStream()
Dim bytesFrom(10024) As Byte
networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize))
Dim dataFromClient As String = \_
System.Text.Encoding.ASCII.GetString(bytesFrom)
dataFromClient = \_
dataFromClient.Substring(0, dataFromClient.IndexOf("$"))
msg("Data from client - " + dataFromClient)
Dim serverResponse As String = \_
"Server response " + Convert.ToString(requestCount)
Dim sendBytes As \[Byte\]() = \_
Encoding.ASCII.GetBytes(serverResponse)
networkStream.Write(sendBytes, 0, sendBytes.Length)
networkStream.Flush()
msg(serverResponse)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End While
clientSocket.Close()
tcpListener.Stop()
msg("exit")
Console.ReadLine()
End Sub
Sub msg(ByVal mesg As String)
mesg.Trim()
Console.WriteLine(" >> " + mesg)
End Sub
End Module
And this is my code for the actual client
Imports System.Net.Sockets
Imports System.Text
Public Class lokMudClient
Dim clientSocket As New System.Net.Sockets.TcpClient()
Dim serverStream As NetworkStream
Private Sub btnConnect\_Click(ByVal sender As System.Object, \_
ByVal e As System.EventArgs) Handles btnConnect.Click
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim buffSize As Integer
Dim outStream As B