HPUX sockets vs Linux?

This is a discussion on HPUX sockets vs Linux? within the Linux Programming forums, part of the Platform Specific Boards category; Hi, After porting a network library from HPUX to Linux, I now need to update the accompanying README files... In ...

  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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    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,246
    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
    Attached Files Attached Files

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    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, 01:10 PM
  4. Need help with Linux sockets
    By junbin in forum Linux Programming
    Replies: 1
    Last Post: 07-21-2002, 12:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21