Пример #1
0
ssize_t sendmsg(int sock, const struct msghdr *msg, int flags)
{
	int r;
	int uds_sotype;

	if (msg == NULL) {
		errno= EFAULT;
		return -1;
	}

	r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype);
	if (r != -1 || errno != ENOTTY) {
		if (r == -1) {
			return r;
		}

		if (uds_sotype == SOCK_DGRAM) {
			return _uds_sendmsg_dgram(sock, msg, flags);
		} else {
			return _uds_sendmsg_conn(sock, msg, flags);
		}

	}

#if DEBUG
	fprintf(stderr, "sendmsg: not implemented for fd %d\n", sock);
#endif

	errno= ENOSYS;
	return -1;
}
ssize_t sendmsg(int sock, const struct msghdr *msg, int flags)
{
	int r;
	int uds_sotype;

	r = __sendmsg(sock, msg, flags);
	if (r != -1 || (errno != ENOTSOCK && errno != ENOSYS))
		return r;

	if (msg == NULL) {
		errno= EFAULT;
		return -1;
	}

	/* For old socket driver implementations, this flag is the default. */
	flags &= ~MSG_NOSIGNAL;

	r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype);
	if (r != -1 || errno != ENOTTY) {
		if (r == -1) {
			return r;
		}

		if (uds_sotype == SOCK_DGRAM) {
			return _uds_sendmsg_dgram(sock, msg, flags);
		} else {
			return _uds_sendmsg_conn(sock, msg, flags);
		}

	}

	errno = ENOTSOCK;
	return -1;
}