l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2004 Feb 29 23:44

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Very slow TCP transfer over loopback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Very slow TCP transfer over loopback

On Sun, Feb 29, 2004 at 06:54:25PM -0800, Ken Herron wrote:
> --On Sunday, February 29, 2004 08:56:42 PM -0500 Mike Simons 
> <msimons@moria.simons-clan.com> wrote:
> >- Anyone have a place to look in the RFCs or such that would explain
> >  why it's waiting, for what?
> Seems pretty quick to me:

That's because I messed up the code pasted into the original message.

I was adding the before/after setsockopt thing as a last minute change
to the code, please try this version instead.  :)

#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>


int main(int argc, char *argv[])
  int accept_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  int option = 1;
  int file;
  socklen_t accept_addr_len;
  struct sockaddr_in accept_addr;
  char buffer[1<<16];

  memset(&accept_addr, 0, sizeof(accept_addr));
  accept_addr.sin_family = AF_INET;
  accept_addr.sin_port = htons(2222);
  inet_aton("", &accept_addr.sin_addr);

  setsockopt(accept_sock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
  bind(accept_sock, (struct sockaddr *) &accept_addr, sizeof(accept_addr));

  listen(accept_sock, 128);

  if (!(argc == 2 && sscanf(argv[1], "%d", &option)))
    option = 1024;

  setsockopt(accept_sock, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));

  accept_addr_len = sizeof(accept_addr);
  file = accept(accept_sock, (struct sockaddr *) &accept_addr, &accept_addr_len);

  if (!(argc == 2 && sscanf(argv[1], "%d", &option)))
    option = 1024;

  setsockopt(file, SOL_SOCKET, SO_RCVBUF, &option, sizeof(option));
  while (read(file, &buffer, sizeof(buffer)));

  return 0;
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.