[Help] Sockets Problem

Discussion in 'Programming General' started by Furbster4, Dec 26, 2008.

[Help] Sockets Problem
  1. Unread #1 - Dec 26, 2008 at 9:09 PM
  2. Furbster4
    Joined:
    Jun 16, 2008
    Posts:
    24
    Referrals:
    0
    Sythe Gold:
    0

    Furbster4 Newcomer

    [Help] Sockets Problem

    Hey its me here,

    I'm attempting to create an IRC Client, but its not working properlly yet...

    It connects to the server, but it doesn't reply to a ping response, so it doesn't stay connected... i want to know why it doesn't send the ping.

    heres the code thats not working
    Code:
            Dim tcpClient As New System.Net.Sockets.TcpClient(), lmao As Integer = "0", _
            message As [Byte]()
    
            tcpClient.Connect("irc.snm.co.nz", 6667)
            Dim networkStream As NetworkStream = tcpClient.GetStream()
            If networkStream.CanWrite And networkStream.CanRead Then
                ' Read the NetworkStream into a byte buffer.
                Do While lmao <> 3
                    Dim bytes(tcpClient.ReceiveBufferSize) As Byte
                    networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
                    ' Output the data received from the host to the console.
                    Dim returndata As String = Encoding.ASCII.GetString(bytes)
                    addText(returndata)
                    lmao = lmao + 1
                Loop
                ' Do a simple write.
                message = Encoding.ASCII.GetBytes("USER Paul 127.0.0.1 irc.snm.co.nz :Paul" & Chr(10))
                networkStream.Write(message, 0, message.Length)
                message = Encoding.ASCII.GetBytes("NICK hello" & Chr(10))
                networkStream.Write(message, 0, message.Length)
                message = Encoding.ASCII.GetBytes("PONG irc.snm.co.nz" & Chr(10))
                networkStream.Write(message, 0, message.Length)
            Else
                If Not networkStream.CanRead Then
                    addText("cannot not write data to this stream")
                    tcpClient.Close()
                Else
                    If Not networkStream.CanWrite Then
                        addText("cannot read data from this stream")
                        tcpClient.Close()
                    End If
                End If
            End If
    
    oh and also, how come when i do

    Code:
    do while tcpClient.Connect = true
    
    actually doesn't work? :p

    like, it works, it won't show the form, until it dies, why? :p
     
< WaitEx() Function :D | Installing SMF 1.1.7 [2 RuneScape accounts level 70+ if done!] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site