Brian, Sorry to put you through this. Here are the files and the dump. On another note, I am going to go digging around in the kernel networking code to see how it works. I was wondering if you could give me some insight as to where I should start. Thanks, Chuck "Brian F. G. Bidulock" wrote: > > Chuck, > > Ok. That settles it. It's a bug. Probably in the sctp_cleanup_rbuf > procedure. I'll chase it later today and release a patch. > > Could you e-mail me directly an Ethereal dump and your two programs > again to save me time in recreating the problem? > > --Brian > > Chuck Winters wrote: Wed, 13 Jun 2001 08:27:41 > > > > Brian, > > I checked the amount of bytes read and it returns 12 each time. I have > > no idea what is going on. > > > > Chuck > > -- > Brian F. G. Bidulock ¦ The reasonable man adapts himself to the ¦ > bidulock@openss7.org ¦ world; the unreasonable one persists in ¦ > http://www.openss7.org/ ¦ trying to adapt the world to himself. ¦ > ¦ Therefore all progress depends on the ¦ > ¦ unreasonable man. -- George Bernard Shaw ¦ -- Chuck Winters | Email: cwinters@atl.lmco.com Distributed Processing Laboratory | Phone: 856-338-3987 Lockheed Martin Advanced Technology Labs | 1 Federal St - A&E-3W | Camden, NJ 08102 |
Attachment:
dump
Description: Binary data
#include <sys/socket.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/uio.h> #include <errno.h> #include <sys/ioctl.h> #include <fcntl.h> #include <sys/uio.h> #include <unistd.h> int main(void) { int listen_sock; int connect_sock; int ct = 0; struct sockaddr_in server_addr; struct sockaddr_in client_addr; int sockaddr_len = 0; char buff[1024]; int on = 1; int buffsize = 0; int bytes_to_read; int bytes_total; int bytes_read_this; struct msghdr message; struct iovec iov; int bytes; memset(&message, 0, sizeof(struct msghdr)); memset(&iov, 0, sizeof(struct iovec)); memset(&server_addr, 0, sizeof(struct sockaddr_in)); memset(&client_addr, 0, sizeof(struct sockaddr_in)); memset(buff, 0, 1024); /** Create a socket **/ if((listen_sock = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { perror("Creating Socket"); exit(1); } fprintf(stderr, "Created socket with fd of %d\n", listen_sock); /** Fill address in **/ server_addr.sin_family = AF_INET; server_addr.sin_port = htons(33822); server_addr.sin_addr.s_addr = inet_addr("192.168.1.33"); iov.iov_base = buff; iov.iov_len = 1024; message.msg_iov = &iov; message.msg_iovlen = 1; message.msg_name = &client_addr; /** Bind address to the socket **/ if(bind(listen_sock, (struct sockaddr* ) &server_addr, sizeof(struct sockaddr_in)) < 0) { perror("Binding to socket"); exit(2); } /** Now listen and accept a connection **/ if(listen(listen_sock, 1) < 0) { perror("Listening"); exit(3); } fprintf(stderr, "After listen\n"); if((connect_sock = accept(listen_sock, (struct sockaddr* ) &client_addr, &sockaddr_len)) < 0) { perror("Accepting\n"); exit(4); } /** Now read from the socket **/ for(ct = 0; ct < 100; ct++) { if((bytes = recvmsg(connect_sock, &message, MSG_WAITALL | MSG_NOSIGNAL)) < 0) { perror("Reading"); exit(1); } fprintf(stderr, "Bytes Read %d\n", bytes); fprintf(stderr, "Client Addres is %s\n", inet_ntoa(((struct sockaddr_in*) message.msg_name)->sin_addr)); fprintf(stderr, "%d) Data received is %s\n", ct, message.msg_iov->iov_base); ioctl(connect_sock, FIONREAD, &buffsize); fprintf(stderr, "Data still in recv buffer is %d\n", buffsize); memset(buff, 0, 1024); bytes = 0; } /** Close the fd **/ close(listen_sock); close(connect_sock); exit(0); }
#include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <stdio.h> #include <string.h> #include <netinet/in.h> #include <stdlib.h> #include <unistd.h> #include <sys/uio.h> #include <signal.h> #include <unistd.h> #include <errno.h> #include <sys/uio.h> int main(void) { int listen_sock; int ct = 0; struct sockaddr_in server_addr; struct sockaddr_in my_addr; char buff[12] = "Hello World"; struct msghdr message; struct iovec iov; iov.iov_base = buff; iov.iov_len = 12; memset(&my_addr, 0, sizeof(struct sockaddr_in)); memset(&server_addr, 0, sizeof(struct sockaddr_in)); signal(SIGPIPE, SIG_IGN); /** Create a socket **/ if((listen_sock = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) { perror("Creating Socket"); exit(1); } fprintf(stderr, "Created socket with fd of %d\n", listen_sock); /** Fill in addr **/ server_addr.sin_family = AF_INET; server_addr.sin_port = htons(33822); server_addr.sin_addr.s_addr = inet_addr("192.168.1.33"); my_addr.sin_family = AF_INET; my_addr.sin_port = htons(1024); my_addr.sin_addr.s_addr = inet_addr("192.168.1.34"); message.msg_name = &server_addr; message.msg_namelen = sizeof(struct sockaddr_in); message.msg_iov = &iov; message.msg_iovlen = 1; message.msg_control = NULL; message.msg_controllen = 0; if(bind(listen_sock, (struct sockaddr* ) &my_addr, sizeof(struct sockaddr_in)) < 0) { perror("Binding"); exit(1); } fprintf(stderr, "Bound to my_addr to socket %d\n", listen_sock); /** Connect to the Server **/ if(connect(listen_sock, (struct sockaddr* ) &server_addr, sizeof(struct sockaddr_in)) < 0) { perror("Connecting"); exit(2); } fprintf(stderr, "Connected to socket %d\n", listen_sock); /** Write to the socket **/ for(ct = 0; ct < 10; ct++) { /*if(send(listen_sock, buff, sizeof(buff), MSG_NOSIGNAL) < 0)*/ if(sendmsg(listen_sock, &message, MSG_NOSIGNAL) < 0) { perror("Problem Sending"); exit(1); } fprintf(stderr, "Sent %s to bert for the %d time\n", buff, ct); sleep(2); } /** close **/ close(listen_sock); exit(0); }