Lyrics Server OnLiNe!

coolradio發表於2009-03-16

忙了一個週末,終於讓歌詞伺服器上線了!

先是在windows機器下用vc寫,除錯比較方便。網頁用PHP真是麻煩,搞不明白PHP的物件、陣列是怎麼寫的,其實是剛開始的時候連變數怎麼寫都不是很清楚,還好看過不多久,立即翻出電子書來查查就能對付了。

[@more@]

在本機上配置apache也花了不少時間,不過始終不完全明白rewrite,配置出來總是有問題,算了,不用rewrite便是了。

忘記了早點傳歌詞資料到伺服器上,傳送的時候才叫痛苦,10Kbps,壓縮後的資料138M(30萬首歌詞),等了N久。

最後在伺服器上編譯歌詞伺服器(Linux),select函式,Windows下第一個引數是沒有意義的,所以之前就隨便寫個0了,而Linux下必須設定為最大的FD+1,網路慢,vi用起來真叫個痛苦!甚好,之前差MSDN的時候,就意識到這個問題,要不等用gdb遠端除錯找出問題來,估計已經自己先瘋了!

感覺PHP對socket支援太原始了,基本上就是把作業系統的服務簡單的提供給使用者。連現成的htonl這樣的函式都要自己先弄,真是麻煩。不過好在,對XML支援挺好的,SimpleXML簡單易用,如果沒有這個東西,在歌詞伺服器和PHP之間按照之前設想的TVL編碼,估計又要多抽一包煙才搞得定了。

歌詞伺服器可以暫時告一段落了,預留問題暫時解決不了--- STL multimap佔用記憶體太厲害了,索引的資料只有30MB,結果程式佔用記憶體100M左右。可以稍微改進一下索引,估計能減少10~20MB記憶體佔用,意義不大,先不弄了,等到歌詞多到記憶體受不了再說吧。

正在聽這首歌曲,留個紀念:



All Summer Long

It was 1989, my thoughts were short my hair was long
Caught somewhere between a boy and man
She was seventeen and she was far from in-between
It was summertime in Northern Michigan
Ahh Ahh Ahh
Ahh Ahh Ahh

Splashing through the sand bar
Talking by the campfire
It's the simple things in life, like when and where
We didn't have no internet
But man I never will forget
The way the moonlight shined upon her hair

[Chorus:]
And we were trying different things
We were smoking funny things
Making love out by the lake to our favorite song
Sipping whiskey out the bottle, not thinking 'bout tomorrow
Singing Sweet home Alabama all summer long
Singing Sweet home Alabama all summer long

Catching Walleye from the dock
Watching the waves roll off the rocks
She'll forever hold a spot inside my soul
We'd blister in the sun
We couldn't wait for night to come
To hit that sand and play some rock and roll

While we were trying different things
And we were smoking funny things
Making love out by the lake to our favorite song
Sipping whiskey out the bottle, not thinking 'bout tomorrow
Singing Sweet Home Alabama all summer long
Singing Sweet Home Alabama all summer long

Now nothing seems as strange as when the leaves began to change
Or how we thought those days would never end
Sometimes I'll hear that song and I'll start to sing along
And think man I'd love to see that girl again

[Repeat Chorus x2]

Singing Sweet Home Alabama all summer long
Singing Sweet Home Alabama all summer long
Singing Sweet Home Alabama all summer long
Singing Sweet Home Alabama all summer long

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21090027/viewspace-1018798/,如需轉載,請註明出處,否則將追究法律責任。

相關文章