日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux socket结构,Linux C socket编程中几个常见的结构体定义

發(fā)布時(shí)間:2023/12/20 linux 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux socket结构,Linux C socket编程中几个常见的结构体定义 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

● sockaddr

#include

struct sockaddr

{

sa_family_t sa_family;

char sa_data[14];

};

● in_addr_t

#include

/* Internet address. */

typedef uint32_t in_addr_t;

struct in_addr

{

in_addr_t s_addr;

};

● in_port_t

#include

/* Type to represent a port. */

typedef uint16_t in_port_t;

● sockaddr_in

#include

struct sockaddr_in

{

sa_family_t sin_family;

in_port_t sin_port;

struct in_addr sin_addr;

unsigned char sin_zero[sizeof (struct sockaddr) -

(sizeof (unsigned short int)) -

sizeof (in_port_t) -

sizeof (struct in_addr)];

};

● addrinfo, servent, protoent, netent, hostent

/* Structure to contain information about address of a service provider. */

struct addrinfo

{

int ai_flags;/* Input flags. */

int ai_family;/* Protocol family for socket. */

int ai_socktype;/* Socket type. */

int ai_protocol;/* Protocol for socket. */

socklen_t ai_addrlen;/* Length of socket address. */

struct sockaddr *ai_addr;/* Socket address for socket. */

char *ai_canonname;/* Canonical name for service location. */

struct addrinfo *ai_next;/* Pointer to next in list. */

};

/* Description of data base entry for a single service. */

struct servent

{

char *s_name;/* Official service name. */

char **s_aliases;/* Alias list. */

int s_port;/* Port number. */

char *s_proto;/* Protocol to use. */

};

/* Description of data base entry for a single service. */

struct protoent

{

char *p_name;/* Official protocol name. */

char **p_aliases;/* Alias list. */

int p_proto;/* Protocol number. */

};

/* Description of data base entry for a single network. NOTE: here a

poor assumption is made. The network number is expected to fit

into an unsigned long int variable. */

struct netent

{

char *n_name;/* Official name of network. */

char **n_aliases;/* Alias list. */

int n_addrtype;/* Net address type. */

uint32_t n_net;/* Network number. */

};

/* Description of data base entry for a single host. */

struct hostent

{

char *h_name;/* Official name of host. */

char **h_aliases;/* Alias list. */

int h_addrtype;/* Host address type. */

int h_length;/* Length of address. */

char **h_addr_list;/* List of addresses from name server. */

#if defined __USE_MISC || defined __USE_GNU

# defineh_addrh_addr_list[0] /* Address, for backward compatibility.*/

#endif

};

總結(jié)

以上是生活随笔為你收集整理的linux socket结构,Linux C socket编程中几个常见的结构体定义的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。