|
-
Aug 3rd, 2004, 03:03 AM
#1
Thread Starter
Registered User
server communication [resolved]
using telnet i can connect to this server (for the freedb music database)
freedb.freedb.org [ port 8880 ]
then i can type the command "sites" to get a list of all current freedb servers...
this is all really easy in telnet.
can somebody help me do this in vb.net?
or send me in the right direction?
any help is ver much appreciated.
thanks...
Last edited by marvinklein; Aug 4th, 2004 at 06:01 PM.
-
Aug 3rd, 2004, 04:29 AM
#2
Do some research on using the System.Net.Sockets namespace to create connections via IP (Telnet is very similar). There are quite a few examples about, so have a look first before asking specific questions.
-
Aug 3rd, 2004, 06:20 AM
#3
Thread Starter
Registered User
Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("freedb.freedb.org", 8880)
Dim networkStream As System.Net.Sockets.NetworkStream = tcpClient.GetStream()
' Read the NetworkStream into a byte buffer.
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 = System.Text.Encoding.ASCII.GetString(bytes)
MessageBox.Show(("Host returned: " + returndata))
If networkStream.CanWrite And networkStream.CanRead Then
' Do a simple write.
Dim sendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes("cddb hello johndoe groton.org mediaplaya 1")
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
ReDim bytes(tcpClient.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
returndata = System.Text.Encoding.ASCII.GetString(bytes)
MessageBox.Show(("Host returned: " + returndata))
Else
MessageBox.Show("err")
End If
End Sub
thats what i came up with...
when i use telnet:
i say: o freedb.freedb.org 8880 'the server returns a msg.
i say: cddb hello johndoe groton.org mediaplaya 1 'the server accepts my login and responds with a msg..
when i use my vb app, i get the first server response as a msgBox, but i don't get the second one...
what is happening here????
Last edited by marvinklein; Aug 4th, 2004 at 04:14 AM.
-
Aug 3rd, 2004, 06:20 AM
#4
Thread Starter
Registered User
sorry about that code. how do i get the proper colorful formatting and line breaks???
-
Aug 3rd, 2004, 01:41 PM
#5
Thread Starter
Registered User
^bump
it can't be that hard...
-
Aug 4th, 2004, 03:46 AM
#6
Edit your posts and just press enter when you have a line end.
Im very busy atm, so cant look into it, Ill check back later for you.
-
Aug 4th, 2004, 07:51 AM
#7
Frenzied Member
instead of 'code' '/code', use 'vbcode' '/vbcode' (brackets, not apostophes)
-
Aug 4th, 2004, 08:47 AM
#8
Just had a couple of mins to look through, and its actually very easy and obvious when you look at it (took me 5 mins). When you connect via telnet, you type your message and press enter. Now you have to do exactly the same thing when going through your code (the same thing you needed to do on your post here as well!), just append a CRLF to the end like your pressing enter.
VB Code:
Dim sendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes("cddb hello johndoe groton.org mediaplaya 1" & vbCrLf)
-
Aug 4th, 2004, 04:43 PM
#9
Thread Starter
Registered User
wow grimfort, i can't express my gratitude enough...
is it usual that messages to a server need to be terminated like that? seems very logical now that i think about it, but i never would have thought of it.
andy- thanks.. that should make my posts a bit clearer from now on...
-
Aug 4th, 2004, 05:56 PM
#10
Yes, with data streams you just keep sending characters. The end connection doesnt know when you have finished typing. Using crlf informs it that you want it to act on everything you just sent to it.
Have fun If you can rename your topic as RESOLVED it saves people trying to answer this .
-
Aug 4th, 2004, 10:49 PM
#11
Frenzied Member
Originally posted by marvinklein
andy- thanks.. that should make my posts a bit clearer from now on...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|