⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ga_unixstruct.c

📁 这个源码是UNIX网络编程卷1一书中的事例源代码
💻 C
字号:
#include	"gai_hdr.h"#ifdef	UNIXDOMAINintga_unixstruct(const char *path, struct addrinfo *hintsp,			  struct addrinfo **result, int socktype){	struct addrinfo		*ai;	struct sockaddr_un	*unp;	if ( (ai = calloc(1, sizeof(struct addrinfo))) == NULL)		return(EAI_MEMORY);	ai->ai_flags = 0;	ai->ai_family = AF_LOCAL;	ai->ai_socktype = socktype;	ai->ai_protocol = 0;		/* allocate and fill in a socket address structure */	ai->ai_addrlen = sizeof(struct sockaddr_un);	if ( (ai->ai_addr = malloc(ai->ai_addrlen)) == NULL)		return(EAI_MEMORY);	unp = (struct sockaddr_un *) ai->ai_addr;	unp->sun_family = AF_UNIX;	strncpy(unp->sun_path, path, sizeof(unp->sun_path));	ai->ai_canonname = NULL;	ai->ai_next = NULL;	*result = ai;	if (hintsp->ai_flags & AI_PASSIVE)		unlink(path);		/* OK if this fails */	return(0);		/* success */}#endif	/* UNIXDOMAIN */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -