+ u.u_error = socreate(uap->domain, &so2, uap->type, uap->protocol);
+ if (u.u_error)
+ goto free;
+ fp1 = falloc();
+ if (fp1 == NULL)
+ goto free2;
+ sv[0] = u.u_r.r_val1;
+ fp1->f_flag = FREAD|FWRITE;
+ fp1->f_type = DTYPE_SOCKET;
+ fp1->f_ops = &socketops;
+ fp1->f_data = (caddr_t)so1;
+ fp2 = falloc();
+ if (fp2 == NULL)
+ goto free3;
+ fp2->f_flag = FREAD|FWRITE;
+ fp2->f_type = DTYPE_SOCKET;
+ fp2->f_ops = &socketops;
+ fp2->f_data = (caddr_t)so2;
+ sv[1] = u.u_r.r_val1;
+ u.u_error = soconnect2(so1, so2);
+ if (u.u_error)
+ goto free4;
+ (void) copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
+ return;
+free4:
+ fp2->f_count = 0;
+ u.u_ofile[sv[1]] = 0;
+free3:
+ fp1->f_count = 0;
+ u.u_ofile[sv[0]] = 0;
+free2:
+ so2->so_state |= SS_NOFDREF;
+ sofree(so2);
+free:
+ so1->so_state |= SS_NOFDREF;
+ sofree(so1);
+}
+
+sendto()
+{
+ register struct a {
+ int s;
+ caddr_t buf;
+ int len;
+ int flags;
+ caddr_t to;
+ int tolen;
+ } *uap = (struct a *)u.u_ap;
+ struct msghdr msg;
+ struct iovec aiov;
+
+ msg.msg_name = uap->to;
+ msg.msg_namelen = uap->tolen;
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ aiov.iov_base = uap->buf;
+ aiov.iov_len = uap->len;
+ msg.msg_accrights = 0;
+ msg.msg_accrightslen = 0;
+ sendit(uap->s, &msg, uap->flags);
+}
+
+send()
+{
+ register struct a {
+ int s;
+ caddr_t buf;
+ int len;
+ int flags;
+ } *uap = (struct a *)u.u_ap;
+ struct msghdr msg;
+ struct iovec aiov;
+
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ aiov.iov_base = uap->buf;
+ aiov.iov_len = uap->len;
+ msg.msg_accrights = 0;
+ msg.msg_accrightslen = 0;
+ sendit(uap->s, &msg, uap->flags);
+}
+
+sendmsg()
+{
+ register struct a {
+ int s;
+ caddr_t msg;
+ int flags;
+ } *uap = (struct a *)u.u_ap;
+ struct msghdr msg;
+ struct iovec aiov[MSG_MAXIOVLEN];
+
+ u.u_error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg));
+ if (u.u_error)
+ return;
+ if ((u_int)msg.msg_iovlen >= sizeof (aiov) / sizeof (aiov[0])) {
+ u.u_error = EMSGSIZE;