https://github.com/ejunjsh/ping
a ping command line from unp
https://github.com/ejunjsh/ping
Last synced: about 1 month ago
JSON representation
a ping command line from unp
- Host: GitHub
- URL: https://github.com/ejunjsh/ping
- Owner: ejunjsh
- License: mit
- Created: 2018-09-15T09:56:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-20T12:46:25.000Z (over 7 years ago)
- Last Synced: 2024-12-29T08:41:56.296Z (about 1 year ago)
- Language: C
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ping
a ping command line from unp, this code just let me pratice the related gcc command.
__Notice: this code only build on macos__
## build share library
gcc lib/*.c -shared -fPIC -o libunp.so -w
## build static library
cd lib/
gcc -c *.c -w
cd -
ar rv libunp2.a lib/*.o
## build executable file with share library
gcc *.c -Ilib/ -o ping -L. -lunp -D__APPLE_USE_RFC_3542 -w
## build executable file with static library
gcc *.c -Ilib/ -o ping -L. -lunp2 -D__APPLE_USE_RFC_3542 -w
## run
# the raw socket need root permission
sudo ./ping www.baidu.com
## check dependencies of executable file
# use share library
otool -L ping
ping:
libunp.so (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
# use static library
otool -L ping
ping:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)