Thread: HPUX sockets vs Linux?

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    HPUX sockets vs Linux?

    Hi,
    After porting a network library from HPUX to Linux, I now need to update the accompanying README files... In one of the files, it says this:
    When server APs running on highly loaded machines handle
    requests from multiple client APs, there may be a problem caused
    by the HP-UX method of accepting TCP/IP connections. In HP-UX
    TCP/IP, pending connections are placed on a stack, rather than
    on a queue. If multiple connection requests come in almost
    simultaneously, the latest connection request is accepted first.
    Thus, on a highly loaded machine, earlier connection requests
    can be buried on the stack and never accepted by the server AP.
    Possible solutions are to reduce the load on the machine running
    the serever AP, or to distribute the server AP to multiple machines.
    Can someone tell me if the same is true for Linux or if I should delete the whole paragraph?

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    Hi,
    After porting a network library from HPUX to Linux, I now need to update the accompanying README files... In one of the files, it says this:

    Can someone tell me if the same is true for Linux or if I should delete the whole paragraph?
    I am decently certain that the Linux accept queue is FIFO not a stack, but it should be easy enough to verify. You could write a little test program which waits for connections and echoes the data to stdout. After calling listen(), go into a sleep state so that connecting clients are forced into the queue. Then dequeue them and see what order they came out of the queue.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    From the listen() man page:
    The backlog parameter defines the maximum length the queue of pending connections may grow to.
    Sounds like Linux does indeed use a queue.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Thanks. I wrote a simple program like brewbuck suggested and saw the sockets answered in FIFO order.

    Code:
    #
    # Client/Server makefile.
    #
    
    ifdef DEBUG_FLAG
      CFLAGS_DBG=-O0 -g -DDEBUG
    else
      CFLAGS_DBG=-O3
    endif
    
    CC=g++
    SRC=.
    CFLAGS=-Wall -I$(SRC) $(CFLAGS_DBG)
    LIBS=
    
    
    all: client server
    
    debug:
    
    
    client: client.o
    	$(CC) -o client client.o $(LIBS)
    
    server: server.o
    	$(CC) -o server server.o $(LIBS)
    
    
    client.o: $(SRC)/client.cpp $(SRC)/AutoClose.h $(SRC)/AutoWinsock.h
    	$(CC) $(CFLAGS) -c $(SRC)/client.cpp
    
    
    server.o: $(SRC)/server.cpp $(SRC)/AutoClose.h $(SRC)/AutoWinsock.h
    	$(CC) $(CFLAGS) -c $(SRC)/server.cpp
    
    
    clean:
    	-rm *.o
    
    clobber:
    	-rm *.o client server

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by bithub View Post
    From the listen() man page:
    Sounds like Linux does indeed use a queue.
    The word "queue" appears in the HP-UX manual too, and yet it is not a queue. I would not depend on the language in this case.

    A listen queue is established for the socket specified by the s
    parameter, which is a socket descriptor.

    backlog defines the desirable queue length for pending connections.
    The actual queue length may be greater than the specified backlog. If
    a connection request arrives when the queue is full, the client will
    receive an ETIMEDOUT error.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with sockets under linux
    By principii in forum Linux Programming
    Replies: 7
    Last Post: 10-20-2010, 02:31 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. A table for errno values by linux sockets?
    By hardi in forum Networking/Device Communication
    Replies: 2
    Last Post: 12-20-2006, 02:10 PM
  4. Need help with Linux sockets
    By junbin in forum Linux Programming
    Replies: 1
    Last Post: 07-21-2002, 12:42 PM