您的位置:首页 > 理论基础 > 计算机网络

【学习笔记】网络编程基础API

2013-11-20 13:41 253 查看
linux网络编程基础API与内核内TC/IP协议族关系。

1. socket地址API

ip地址及端口对,代表TCP通信中的一方,称为socket地址。

socket就像pipe一样,代表的是一个文件描述符。可以用socket()来创建。

参考 http://man7.org/linux/man-pages/man2/socket.2.html

#include <sys/types.h>          /* See NOTES */
       #include <sys/socket.h>

       int socket(int domain, int type, int protocol);


返回一个文件描述符。

注意,与pipe不同的是,socket可以用来在无关的进程甚至是通过network使得两个不同机器的进程间进行通信。

参考http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_11.html

Sockets are the primary meansof communicating with other machines; telnet, rlogin, ftp, talk, and the other familiar network programs use sockets.

2.socket 基础API

sys/socket.h

http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html

在这里/article/3669288.html

3.网络信息API

主机名和IP地址的转换,服务名和端口号之间的转换。在netdb.h中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: