Solved

trying to get simple connection to irc

Posted on 2006-11-11
11
271 Views
Last Modified: 2010-04-23
im trying to send a logon string to a irc server and capture the return how do i do this

ive been trying with the below code but it does not work...

            Connect(txtServer.Text, txtPort.Text, "NICK " & txtBaseNick.Text & Index & vbLf & "USER TEST tst text :text" & Index & vbLf & "PONG :mkv" & vbLf & "JOIN " & txtChannel.Text & vbLf)


   Sub Connect(ByVal server As [String], ByVal irc_port As Int32, ByVal message As [String])
        Try
            ' Create a TcpClient.
            ' Note, for this client to work you need to have a TcpServer
            ' connected to the same address as specified by the server, port
            ' combination.
            Dim port As Int32 = irc_port
            Dim client As New TcpClient(server, port)

            ' Translate the passed message into ASCII and store it as a Byte array.
            Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)

            ' Get a client stream for reading and writing.
            '  Stream stream = client.GetStream();
            Dim stream As NetworkStream = client.GetStream()

            ' Send the message to the connected TcpServer.
            stream.Write(data, 0, data.Length)

            Console.WriteLine("Sent: {0}", message)
            Form1.ListBox1.Items.Add("Sent: " & message)
            'My.Application.DoEvents()
            ' Receive the TcpServer.response.
            ' Buffer to store the response bytes.
            data = New [Byte](256) {}

            ' String to store the response ASCII representation.
            Dim responseData As [String] = [String].Empty

            ' Read the first batch of the TcpServer response bytes.
            Dim bytes As Int32 = stream.Read(data, 0, data.Length)
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
            Console.WriteLine("Received: {0}", responseData)
            Form1.ListBox2.Items.Add("Received: " & responseData)
            'My.Application.DoEvents()
            ' Close everything.
            stream.Close()
            client.Close()
        Catch e As ArgumentNullException
            Console.WriteLine("ArgumentNullException: {0}", e)
        Catch e As SocketException
            Console.WriteLine("SocketException: {0}", e)
        End Try

        'Console.WriteLine(ControlChars.Cr + " Press Enter to continue...")
        'Console.Read()
    End Sub 'Connect
0
Comment
Question by:Johnny
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17921167
What error do you get, and where?
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 500 total points
ID: 17921226
If you could understand C# here is a library for IRC in C#

http://www.codeproject.com/cs/internet/smartirc4net.asp
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17921228
or you could use it's compiled dll in your vb.net application without converting it :)
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 13

Expert Comment

by:newyuppie
ID: 17921395
if that code, works he can even add the whole C# code as a separate project on his VB application and it would work too.
0
 

Author Comment

by:Johnny
ID: 17921462
im not getting a full connection..it send the info, and gets back the info

maybe im missing the logon itself.. besides what im sending to login to join a room

0
 
LVL 29

Expert Comment

by:Nightman
ID: 17921483
Perhaps you could give the library from mohzedan a try. It also looks to be well documented, with some examples as well.
0
 

Author Comment

by:Johnny
ID: 17923701
went with the smart irc code.... having problems converting it

hopefully it will be ok tho

thanks for the help on to converting it questions
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_22057410.html
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17924582
You don't need to convert it. ... you should just build the project and add the dll as a reference to your project and use it as is
0
 

Author Comment

by:Johnny
ID: 17925586
theres no vb.net example code so to have c code converted it all there is...


i did most of it..and have it connecting...im trying to show the sends and the replies now..then ill be ok having problems with that..i was gonna open another question sometime for ask how to do that..if i cnat figure it out soon
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17926267
why don't you post the c# example code here and I'll convert it for you ?
0
 

Author Comment

by:Johnny
ID: 17926614
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF - Tooltips for ComboBox items 5 74
Advice on Xojo as a development tool over VB. 4 56
Help with exporting to excel 4 28
VB.Net Tranfer data between to VB.Net apps 8 26
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question