![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
danke an alle. Die Info war gut, denn MPD setzt für die Kommunuikation zwischen Client und Server TCP als Übertragungsprotokoll ein. Somit kann ich vom Sofa aus meine Stereoanlage fernsteuern und kann die Musik genießen ohne mich bewegen zu müssen. Gruß Mamuen |
|
|||
|
Quote:
Ich hab jetzt meine ersten gehversuche hinter mir. Auf meinem LinuxSoundserver läuft der MPD-Dämon und mittels TCPDump überwache ich die WLanschnittstelle. Nachdem ich eine Verbindung mittels meines Progs aufzubauen versuche, sehe ich in TCPDump ein von mir gesendetes IP-Paket. Dieses wird mehrmals gesendet aber es kommt zu keinem Verbindungsaufbau (3-Wegehandshake bei TCP). Die Firewall ist ausgeschaltet. Per Webbrowser bekomme ich aber Zugriff auf die Linuxbüchse. Tja, da bleibt nur noch die eigene Unfähigkeit (Programmierkunst) übrig. Ich versuch mal mein Prog anzuhängen und hoffe, dass einer einen Fehler findet. Gruß Mamuen |
|
|||
|
Hi,
ich habe eine kleine Erfolgsmeldung zu berichten, nachdem ich den Port von 6600 auf 80 geändert habe, bekam ich keine Fehlermeldung mehr (Resssource konnte nicht mehr gefunden werden). Statt dessen bekam ich natürlich Fehlermeldungen von meinem Webserver. Werde wohl noch ein Bischen mit dem Protokoll von MPD experimentieren müssen. Gruß mamue |
|
|||
|
Hi brathbone,
Thanke you for your interest. I have check it at http://mpd.wikia.com/wiki/MusicPlaye...rotocolOutline There you can read: "The client transmits a command sequence, terminated by a newline." "Each server response ends with a completion code. There are two codes: OK and ACK." My problem is now, the prog. reads only about 33600 bytes not the whole stream. By the next trasmitted newline the prog. will receive the rest. Sub Globals 'Declare the global variables here. Dim bufferbits(0) As byte End Sub Sub App_Start Form1.Show End Sub Sub btnSetSRV_Click bit.New1 client.New1 client.Connect ("192.168.200.1",6600) stream.New1(client.GetStream,false) Do While client.DataAvailable = false Loop Dim bufferbits(128) As byte count = stream.ReadBytes(bufferbits(),128) buffer = bit.BytesToString(bufferbits(),0,count) txtAntwort.Text = buffer Label5.Text = "Connected to 192.168.200.1:6600" Form2.Show End Sub Sub btnSend_Click stream.WriteBytes (stream.StringToBytes(txtBefehl.Text & Chr(10)) ) timer1.Enabled = true End Sub Sub Timer1_Tick If client.DataAvailable = true Then Dim bufferbits(102400) As byte count = stream.ReadBytes(bufferbits(),102400) buffer = bit.BytesToString(bufferbits(),0,count) buffer = StrReplace (buffer,Chr(10),crlf) 'linefeed to crlf txtAntwort.Text = buffer txtcount.Text = count End If timer1.enabled = false txtBefehl.Focus End Sub Sub btnExit_Click client.Close AppClose End Sub Best wishes, Mamuen |
|
||||
|
mamuen,
Thanks for reminding me that I have to be more careful about waiting for all the data to arrive. So let's say the server sends two commands like: 220 then a bunch of other text & CRLF 240 something else & CRLF We might get "220 then" when we check for incoming data, and then we might get "a bunch of other text" & chr(13) & chr(10) & "240 Something el" and then might get "se" & chr(13) & chr(10) on our next check. The trick here is going to be to use a global variable to store our incomplete commands between checking for data. Then when we check for data, we check to see if there is a terminator in it (chr(13) & chr(10)) using something like: If StrIndexOf(stringbuffer,chr(13) & chr(10),0) > -1 We can't assume that the terminator is the last part of our data, since we may have received part of the next message as well, so if there is a terminator, take everything before the terminator, append it to whatever may have come in before (our global variable) and then act accordingly. Of course we need to look for additional terminators or partial data before proceeding. If we don't have a terminator, then append the data to our global variable. I don't have this code written in Basic4PPC yet, but here is pseudo-code based on what my REALbasic code does: count = stream2.ReadBytes(bufferbits(),8192) stringbuffer = bit.BytesToString(bufferbits(),0,count) '//look for a terminator in our new data i = StrIndexOf(stringbuffer,CHR(13) & CHR(10),0) if i > -1 then '//loop though and process commands until we run out of terminators do while i > -1 '//parse out everything before the first terminator '//append it to any existing data in our global variable '//process the command '//look for additional terminators in existing data i = StrIndexOf(stringbuffer,CHR(13) & CHR(10),i) loop else '//no terminator in this batch of data '//append text to global variable and wait for more data. end if hope that helps,
__________________
Brian Rathbone Laptop: AMD Turion 64 Mobile 2ghz, 2GB RAM, Dual GeForce Go 7900 GTX 768MB SLI, Dual 200GB HDD at RAID0. XP Pro sp2 Device: Treo 750, WM6, 300mhz,128MB RAM, 2GB miniSD, 240x240 display |
|
|||
|
Hi brathbone,
your way i think is the clean way. I found a other solution (quick and dirty), but it works. The endstring of transmision is always "OK"+crlf. endstr = 0 Dim bufferbits(4096) As byte If client.DataAvailable = true Then Do count = stream.ReadBytes(bufferbits(),4096) buffer = bit.BytesToString(bufferbits(),0,count) buffer = StrReplace (buffer,Chr(10),crlf) 'linefeed to crlf If SubString (buffer,StrLength(buffer)-4,2)="OK" Then endstr = 1 Else If SubString (buffer,0,3)="ACK" Then endstr = 2 End If txtAntwort.Text = txtAntwort.Text & buffer Loop While endstr = 0 txtcount.Text = endstr End If Regards manuen |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MPD client for Windows Mobil | mamuen | Open Source Projects | 1 | 06-01-2008 12:21 PM |
| Use Network.Client to get the definition of a word from Dict.org | brathbone | Code Samples & Tips | 9 | 03-09-2008 03:34 AM |
| FTP Client | PatrikL | Share Your Creations | 2 | 05-05-2007 06:54 AM |