# Linux Network Programming, by WhoAmI ###### tags: `C LANGUAGE` `linux` `network programming` <style> .blue { color: blue; } .bgblue { color: blue; font-size: 24px; font-weight: bold; } .red { color: red; font-size: 24px; font-weight: bold; } </style> Authors: WhoAmI, CrazyMonkey email: kccddb@gmail.com Date: 20221217 Copyright: CC BY-NC-SA ![](https://i.imgur.com/sLSy0lS.png) **Do your best to be ethical and respect copyright.** [家扶基金會](https://www.ccf.org.tw/support/donate/channel) [台灣之心愛護動物協會](https://www.hotac.org.tw/donate) [無國界醫生](https://www.msf.org.tw/about-us/who-we-are) **這裡的內容 適合 資電大三以上 學過網路, Linux 與 c 語言的人士** **開始練習 看 man page 與 良好的程式設計習慣, 例如 MT-Safe(Multi Thread Safe), data type (資料型態)...等** **至於 效能 請 學好 Probability, Statistics, OS and Algorithm 等** **c Language:** [ANSI C for Programmers on UNIX Systems, Tim Love](https://www.cs.utexas.edu/~dahlin/Classes/UGOS/reading/loveC.pdf) [C 也可以寫的很OOP 簡單範例與簡易Makefile](https://hackmd.io/@pingulinux/c-oop) putty or MobaXterm Ubuntu-16.04, VirtualBox Win32 Editor: [Komodo Edit](https://www.activestate.com/products/komodo-edit/) **Learn iproute2** ip addr ip route Learn commands: vim, nano, wget, sudo, cd, ls, cp, cat, more, find, ln, grep, ps, chmod, chown, tar, mkdir, rm, rmdir, df, du, kill, echo, ping, strace, top, strip, route, ifconfig, arp, pstree, touch, netstat, ldd, pstree, objdump, gunzip, gzip, bzip2, dmesg, pwd, which, iptables, brctl, iproute2 ip command ... 其實我自己較 **"懶"** shell commands 自己學(其實 也沒時間教) [簡明 Linux Shell Script 入門教學](https://blog.techbridge.cc/2019/11/15/linux-shell-script-tutorial/) 了解 [linux 檔案架構與主要用途](https://linyunwen.github.io/2020/10/01/linux-fs/) [Linux Command Cheat Sheet](https://www.golinuxcloud.com/linux-commands-cheat-sheet/) 資電的練習 看 8051 datasheet, **培養 看 datasheet 的習慣** ![](https://i.imgur.com/Vv7eW55.png) 安裝與學習實用的工具軟體: [Wireshark](https://www.wireshark.org/) --- [Learn How to Use Wireshark like a PRO](https://www.golinuxcloud.com/how-to-use-wireshark/) 過去我自己的教學慣例: 期末作業是傳4G 的檔案, 要處理 網路斷線多次 (斷電, 拔網路線, 蓋金屬盒子, [NMAP](https://nmap.org/) 等...), <span class="blue">頻寬不同 </span>並可續傳的 client/server, 事實上實作 不容易, 但學生可以體會很多實務上的問題 注意 傳檔案大小時, 注意 byte order 的問題 ( **client/server 會遇到 不同 byte order 問題**) 很多 用 ping xx.xx.xx.xx 偵測網路通不通~真的完整嗎? Why? (**這問題 對 非通訊電子了解的人士 算難**) ping 可以, 但有時使用不行, 或不穩定 **Hint**: noise,interference, 接觸不良, ... [使用 Netstat 指令檢測網路的技巧, by G. T. Wang](https://blog.gtwang.org/linux/linux-netstat-command-examples/) [7-Zip](https://www.7-zip.org/) <span class="red">**網路程式會動很容易, 穩定與效能才是重點**</span> **個人 覺得 網路程式設計 最好 星期六 日 10:00~12:00 13:00~16:00 3~4 星期 結束, 可惜 學校不是 如此** 學校也可收業界的人士~死腦筋 --- ![](https://i.imgur.com/6giMHfZ.jpg) ![](https://i.imgur.com/1AmtJ8x.jpg) --- **COURSE OUTLINE** --- ## [Basic c programming](https://hackmd.io/@pingulinux/basic-c) ## [TCP Client/Server](https://hackmd.io/@pingulinux/AF_INET-server) ## [Process State-fork, exit, wait, signal](https://hackmd.io/@pingulinux/Process-State-fork-exit-wait-signal) ## [C 也可以寫的很OOP 簡單範例與簡易Makefile](https://hackmd.io/@pingulinux/c-oop) ## [Simple OOP TCP server](https://hackmd.io/@pingulinux/SimpleOOPTCP) ## [Interrupt, ISR probrem](https://hackmd.io/@pingulinux/isr-interrupt-top-half) ## [select system call-synchronous I/O multiplexing](https://hackmd.io/@pingulinux/select-system-call) ## [TCP Client/Server (select) 運作觀念](https://hackmd.io/@pingulinux/select) ## [UDP Client/Server (select)](https://hackmd.io/@pingulinux/udps) ## [pthread 的 echo server (注意 有 bug!)](https://hackmd.io/@pingulinux/pthread-echo-bug) ## [Embedded Linux System, Boot, Linux VFS, System Call, SPI, GPIO, … 課程基礎原理](https://hackmd.io/@pingulinux/emlinux) ## [c language: function pointer, callback and event-driven](https://hackmd.io/@pingulinux/function-pointer-callback) ## [*popen, select, PHP client, 執行遠端程式](https://hackmd.io/@pingulinux/popen-select-PHP) ## [Sniff frames 設計 tcpdump, Wireshark 基本原理](https://hackmd.io/@pingulinux/sniffframe) ## [volatile and optimization 影響效能的關鍵之一](https://hackmd.io/@pingulinux/volatile-and-optimization) ## [HTTP 1.0 web server+CGI-sample code](https://hackmd.io/@pingulinux/HTTP-1-0-web-server-CGI) ## [Linux I/O redirection](https://hackmd.io/@pingulinux/io-redirection) ## [*Pthread Scheduling, Fairness, Power, Performance](https://hackmd.io/@pingulinux/Pthread-Scheduling-Fairness-Power) ## [*CServer class, callback function, pthread, non-blocking connect simple and basic HTTP server ](https://hackmd.io/@pingulinux/server-class-callback-non-blocking) ## [QoS, Load Balancing and Policy Route (iproute2, netlink socket)](https://hackmd.io/@pingulinux/qostc) ## [Application (Linux firewall, QoS and route): Linux iptables and iproute2](https://hackmd.io/@pingulinux/firewall-route) ## [SMTP (Simple Mail Transfer Protocol )](https://hackmd.io/@pingulinux/smtp) --- [有意修習 (或未來)embedded system 課的同學](https://hackmd.io/@pingulinux/prerequisite) [libusb](https://libusb.info/) --- Learn commands: (請看 man page) vim, nano, wget, sudo, cd, ls, cp, cat, more, find, ln, grep, ps, chmod, chown, tar, mkdir, rm, rmdir, df, du, kill, echo, man, top, ping, which, touch, pstree, strace, strip, netstat, lsmod, insmod, rmmod, modinfo, bzip2, gunzip, tcpdump, mount, umount, dd, objdump, gzip, mke2fs, tee, tail, dmesg, reboot, sync, cpio, losetup, strip -g (Remove debugging symbols only), ... [Linux 匹配文字 grep 指令用法教學與範例, by G. T. Wang](https://blog.gtwang.org/linux/linux-grep-command-tutorial-examples/) [Regular Expression in Linux](https://data-flair.training/blogs/regular-expression-in-linux/#:~:text=Regular%20expressions%20are%20special%20characters%20in%20Linux-based%20operating,like%20grep%2C%20sed%2C%20tr%2C%20ed%2C%20awk%2C%20and%20vi.) [Linux Command Cheat Sheet](https://www.golinuxcloud.com/linux-commands-cheat-sheet/) [Nmap-the Network Mapper - Free Security Scanner ](https://nmap.org/) [Nmap Network Scanning The Official Nmap Project Guide to Network Discovery and Security Scanning](https://nmap.org/book/toc.html) 裡面 有 bzero , 請改用 memset, 可見是 前輩! 自己 SSL 有版權問題 不方便 公開免費使用 應用 例如 學校用 e-mail 認證( DNAT+POP3) Wifi 密碼 [ssl server client programming using openssl in c](https://aticleworld.com/ssl-server-client-using-openssl-in-c/) --- **websocket** [Theldus/wsServer](https://github.com/Theldus/wsServer) --- **以下比較適合 大四 研一** ## [山不在高 有仙則名](https://hackmd.io/@pingulinux/books) ## [安裝arm-2013.11-33-arm-none-linux-gnueabi toolchain 與 小的測試 rootfs, init 給 QEMU](https://hackmd.io/@pingulinux/toolchain) ## [編譯 ARM Busybox 1.22.0 當 Rootfs for QEMU Linux](https://hackmd.io/@pingulinux/ARMBusybox) ## [Linux simple sysfs and procfs demo (Linux kernel >3.2)](https://hackmd.io/@pingulinux/sysfs-procfs) ## [Add a system call (in X86 QEMU Environment)](https://hackmd.io/@pingulinux/add-system-call)