instruments remote exception encountered

Posted on

solution:
make sure your Xcode set the Profile scheme as Debug than Release.

廣告

Grab Screen from Mac OS X Lion(10.7)

Posted on

Mac OS X Lion seams disable OpenGL screen. So, glReadPixel can’t get screen shot.
The solution to grab the screen:
CGImageRef image = CGDisplayCreateImage(kCGDirectMainDisplay);

TCP 常見問題 1 : 如何知道對方不正常斷線?

Posted on Updated on

問題: Peer A & Peer B 已經建立連線。但是Peer B突然電源線被拉掉,也沒電池撐著,或是突然B端的網路線被拉掉。這時候Peer A 的應用程式也沒有對B進行資料的收送。等到下次要搜送資料的時候,卻卡在send recv or read/write 當中。怎辦?
解法;利用 tcp keep alive.在socket 建立的時候 加上
int optval = 1 ;
setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (const S8 *)&optval, sizeof(optval))
optval = 10 ; // seconds
setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE, (const S8 *)&optval, sizeof(optval))
optval 設定成 timeout 的時間。這個timeout發生的時候, tcp 會送一個 SYN 給對方。

http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/programming.html#setsockopt

windows mysql reset root

Posted on Updated on

http://dev.mysql.com/doc/mysql-windows-excerpt/5.0/en/resetting-permissions-windows.html

1. stop mysql service.
2. edit a file abcd.sql
UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass’) WHERE User=’root’;
FLUSH PRIVILEGES;
3. mysqld.exe –console –init-file=abcd.sql
4. new root password = MyNewPass