- 包裹函數
爲了包邊檢查程序中出現的錯誤,我們可通過定義包裹函數來縮短程序,每個包裹函數完成實際的函數調用,檢查返回值,並按照發生錯誤時終止進程。包裹函數中的函數名採用實際函數名的首字母大寫的形式。
sockfd=Socket(AF_INET, SOCK_STREAM, 0);
int Socket(int family, int type, int protocol){
int n;
if ( (n=socket(family, type, protocol)) < 0)
err_sys("Socket error");
return(n);
}
- 未完待續