# 5. System call 或 Bust

我們在本章開始討論如何讓你存取 UNIX 系統或 BSD、Windows、Linux、Mac 等系統的 system call（系統呼叫）、socket API 及其它 function calls（函式呼叫）等網路功能。當你呼叫其中一個函式時，kernel 會接管，並且自動幫你處理全部的工作。

多數人會卡在這裡是因為不知道要用什麼樣的順序來呼叫這些函式，而你在找 man 使用手冊時會覺得手冊很難用。好的，為了要幫忙解決這可怕的困境，我已經試著在下列的章節精確地勾勒出（layout） system call，你在寫程式時只要照著一樣的順序呼叫就可以了。

為了要連結一些程式碼，需要一些牛奶跟餅乾［這恐怕你要自行準備］，以及一些決心與勇氣，而你就能將資料發送到網際網路上，彷彿是 Jon Postel 之子般。

［請注意，為了簡潔，下列許多程式碼片段並沒有包含錯誤檢查的程式碼。而且它們很愛假設呼叫 getaddrinfo() 的結果都會成功，並會傳回鏈結串列（link-list）中的一個有效資料。這兩種情況在單獨執行的程式都有嚴謹的定位，所以，還是將它們當作模型來使用吧。］


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beej-zhtw.netdpi.net/05-system-call-or-bust.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
