#include "cc352.h" #include <netinet/tcp.h> int main(int argc, char **argv) { int fd; //socket descriptor int sndbuff = 32*1024; //send buffer int rcvbuff = 32*1024; int error;//to hold the errocode socklen_t len; // option len for getsock //create the socket. fd = socket(AF_INET,SOCK_STREAM,0); //call the socket option error = setsockopt(fd,SOL_SOCKET, SO_SNDBUF,&sndbuff, sizeof(sndbuff)); //setsockopt return 0 when it is ok -1 for error if(error) { printf("Set sockopt fails!n"); return -1; } //set the rcv buffer. error = setsockopt(fd,SOL_SOCKET, SO_RCVBUF,&rcvbuff, sizeof(rcvbuff)); if(error) { printf("Set socket option fail!n"); return -1; } //checking the values error = getsockopt(fd,SOL_SOCKET, SO_SNDBUF,&sndbuff,&len); if(error) { printf("Get Socket option fails!n"); return -1; } error = getsockopt(fd,SOL_SOCKET, SO_RCVBUF,&rcvbuff,&len); if(...
Posts
Showing posts from September 2, 2007