Date: Tue, 21 Dec 2010 15:09:26 +0330 From: Mohammad Hedayati <hedayati.mo@gmail.com> To: freebsd-net@freebsd.org Subject: SOCK_STREAM socket in kernel space Message-ID: <AANLkTinL8HRex1FBi5fmbi216rW256mJc7nBu9J1%2B=OC@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
I'm about to use a char device for a kind of distributed processing, so I've coded the open function as follows. The problem is that soaccept returns 0 without populating the raddr. I've checked netstat, everything seems to be fine, the socket is created, bound and the state is LISTENING. Even the remote is connection is ESTABLISHED. But, it cannot receive anything. it says that socket (sock variable) is not connected. int open(struct cdev *dev, int flag, int otyp, struct thread *td) { uprintf("in open...\n"); int error = -1; socktd = td; error = socreate(AF_INET, &sock, SOCK_STREAM, IPPROTO_TCP, td->td_proc->p_ucred, socktd); if(error != 0) return error; sockaddr.sin_len = sizeof(struct sockaddr_in); sockaddr.sin_family = AF_INET; sockaddr.sin_port = htons(1234); sockaddr.sin_addr.s_addr = INADDR_ANY; error = sobind(sock, (struct sockaddr *)&sockaddr, socktd); uprintf("sobind error = %d\n", error); error = solisten(sock, 5, socktd); uprintf("solisten error = %d\n", error); error = soaccept(sock, (struct sockaddr **)&raddr); uprintf("soaccept error = %d, ip=%s\n", error, inet_ntoa(raddr->sin_addr)); uprintf("out open...\n"); return(error); } int read(struct cdev *dev, struct uio *uio, int ioflag) { int error = 0; error = soreceive(sock, (struct sockaddr **)&raddr, uio, NULL, NULL, NULL); return(error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinL8HRex1FBi5fmbi216rW256mJc7nBu9J1%2B=OC>