Click here to Skip to main content
15,893,401 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralIssue when create popup calendar.... Pin
Golden Jing13-Dec-09 14:49
Golden Jing13-Dec-09 14:49 
GeneralRe: Issue when create popup calendar.... Pin
EliottA14-Dec-09 3:34
EliottA14-Dec-09 3:34 
GeneralRe: Issue when create popup calendar.... Pin
Golden Jing14-Dec-09 20:07
Golden Jing14-Dec-09 20:07 
GeneralRe: Issue when create popup calendar.... Pin
EliottA15-Dec-09 3:25
EliottA15-Dec-09 3:25 
QuestionVB Form Commands in TextBoxes Pin
Dimz9313-Dec-09 4:10
Dimz9313-Dec-09 4:10 
AnswerRe: VB Form Commands in TextBoxes Pin
EliottA13-Dec-09 17:25
EliottA13-Dec-09 17:25 
AnswerRe: VB Form Commands in TextBoxes Pin
Eddy Vluggen14-Dec-09 0:59
professionalEddy Vluggen14-Dec-09 0:59 
QuestionNo Connection? Pin
teknozwizard12-Dec-09 21:25
teknozwizard12-Dec-09 21:25 
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 Byte() = _
        System.Text.Encoding.ASCII.GetBytes("Message from Client$")
        serverStream.Write(outStream, 0, outStream.Length)
        serverStream.Flush()

        Dim inStream(10024) As Byte
        buffSize = clientSocket.ReceiveBufferSize
        serverStream.Read(inStream, 0, buffSize)
        Dim returndata As String = _
        System.Text.Encoding.ASCII.GetString(inStream)
        msg("Data from Server : " + returndata)
    End Sub

    Private Sub lokMudClient_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
        msg("Client Started")
        clientSocket.Connect("204.209.44.6", 6100)
        outputBox.Text = "Client Socket Program - Server Connected ..."
    End Sub

    Sub msg(ByVal mesg As String)
        outputBox.Text = outputBox.Text + Environment.NewLine + " >> " + mesg
    End Sub
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click
        dialogsForm.Show()
    End Sub
End Class


Now, for some reason, I can't see any output in my 'outputBox' which I've set inside a panel labelled 'outputHolder.' So, I'm a little lost as to which direction I need to be going with this. I thought I had it down, but I guess I don't....

P.S. I'm not getting any errors, but I am getting a warning which reads:

"'Public Sub New(port As Integer)' is obsolete. 'This method has been depracated. Please use TcpListener(IPAddress localaddr, int port).'

And it can be found on line 5, column 13 of the tcpListener project. Could this be the reason I'm not finding any text in the rich text box I'm trying to use to hold the output of the server? Suggestions, fixes, please provide and thank you in advance.
QuestionHelp with VB 2008.NET, Please [modified] PinPopular
treashunter10-Dec-09 20:21
treashunter10-Dec-09 20:21 
AnswerRe: Help with VB 2008.NET, Please Pin
Johan Hakkesteegt10-Dec-09 22:27
Johan Hakkesteegt10-Dec-09 22:27 
GeneralRe: Help with VB 2008.NET, Please Pin
treashunter10-Dec-09 22:36
treashunter10-Dec-09 22:36 
GeneralRe: Help with VB 2008.NET, Please Pin
Tom Deketelaere10-Dec-09 23:42
professionalTom Deketelaere10-Dec-09 23:42 
GeneralRe: Help with VB 2008.NET, Please Pin
treashunter10-Dec-09 23:49
treashunter10-Dec-09 23:49 
GeneralRe: Help with VB 2008.NET, Please Pin
Tom Deketelaere10-Dec-09 23:57
professionalTom Deketelaere10-Dec-09 23:57 
GeneralRe: Help with VB 2008.NET, Please Pin
treashunter11-Dec-09 0:06
treashunter11-Dec-09 0:06 
GeneralRe: Help with VB 2008.NET, Please Pin
dan!sh 11-Dec-09 0:11
professional dan!sh 11-Dec-09 0:11 
GeneralRe: Help with VB 2008.NET, Please Pin
The Man from U.N.C.L.E.11-Dec-09 23:06
The Man from U.N.C.L.E.11-Dec-09 23:06 
GeneralRe: Help with VB 2008.NET, Please Pin
Paul Conrad12-Dec-09 4:56
professionalPaul Conrad12-Dec-09 4:56 
GeneralRe: Help with VB 2008.NET, Please Pin
Johan Hakkesteegt11-Dec-09 2:37
Johan Hakkesteegt11-Dec-09 2:37 
AnswerRe: Help with VB 2008.NET, Please Pin
Paul Conrad12-Dec-09 4:59
professionalPaul Conrad12-Dec-09 4:59 
QuestionHow to check Internet connection Pin
Tufail Ahmad10-Dec-09 18:28
Tufail Ahmad10-Dec-09 18:28 
AnswerRe: How to check Internet connection Pin
Eddy Vluggen11-Dec-09 2:13
professionalEddy Vluggen11-Dec-09 2:13 
GeneralRe: How to check Internet connection Pin
Tufail Ahmad11-Dec-09 19:00
Tufail Ahmad11-Dec-09 19:00 
GeneralRe: How to check Internet connection Pin
The Man from U.N.C.L.E.11-Dec-09 23:09
The Man from U.N.C.L.E.11-Dec-09 23:09 
AnswerRe: How to check Internet connection Pin
εїзεїзεїз12-Dec-09 0:32
εїзεїзεїз12-Dec-09 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.