sosend() and mbuf
Maslan
maslanbsd at gmail.com
Mon Aug 3 08:44:45 UTC 2009
Hello Guys,
I can't find useful information on sosend(), I would like to send some
plain text through sosend()
Here is what i got so far, I don't know how to use mbuf with sosend()
to achieve this.
ret = socreate(PF_INET, &s, SOCK_STREAM, IPPROTO_TCP,
curthread->td_ucred, curthread);
printf("socreate -> %d\n", ret);
bzero(&sa, sizeof(sa));
sa.sin_len = sizeof(sa);
sa.sin_family = AF_INET;
sa.sin_port = htons(8888);
sa.sin_addr.s_addr = INADDR_ANY;
sobind(s, (struct sockaddr *)&sa, curthread);
printf("sobind -> %d\n", ret);
ret = solisten(s, 4, curthread);
printf("solisten -> %d\n", ret);
ret = soaccept(s, (struct sockaddr**)&psa);
printf("soaccept -> %d\n", ret);
tsleep(curthread, PDROP, "kHTTP tsleep", 10*hz);
/* iovec */
aiov.iov_base = buf;
aiov.iov_len = strlen(buf);
/* auio */
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_offset = 0;
auio.uio_resid = strlen(buf);
auio.uio_rw = UIO_WRITE;
auio.uio_segflg = UIO_SYSSPACE;
auio.uio_td = curthread;
--------> ret = sosend(s, (struct sockaddr*)&sa, &auio, 0, 0, 0, curthread);
printf("sosend -> %d\n", ret);
ret = soclose(s);
printf("soclose -> %d\n", ret);
Thanks a lot
More information about the freebsd-hackers
mailing list