LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Socket Programming: setsockopt: Protocol not available (https://www.linuxquestions.org/questions/programming-9/socket-programming-setsockopt-protocol-not-available-199130/)

bonhomme 06-29-2004 12:12 PM

Socket Programming: setsockopt: Protocol not available
 
Hi all,

I'm trying to connect a Linux box (running RH7.2) to a UNIX system via a C program I've written. The issue I'm having is that once the code gets to a setsockopt( ) system call, it returns with the error "Protocol not available". I've tried to do Google searches on the problem but all I get back are IP masquing issues which is not what I'm doing here.

The setsockopt calls are in the 2nd code segment. I've modified the code a little so that it's easier to read here on the board. Pardon any stupid mistakes I've done. Here's what I have so far:
Code:

int HDC_init (unsigned char** HDC_allocptr)
{
        int status;

        /* Create a TCP client socket and connect to the SBC1 server */
        s_addr = inet_addr (SBC1_IP);
        printf ("s_addr = %d \n", s_addr);
        sin_port = SBC1_PORT;


        status = ipcConnect (SBC1_NAME, sin_port, s_addr, RNR_NONBLOCKING, SBC1_SERVNUM);

/*some other irrelevant code down here*/
}

....and here's the ipcConnect function:
Code:

int                clientSocket[MAX_PORTS];

int ipcConnect( char *hostname, unsigned int bindAddress, unsigned int netAddress, int block_type, int serverNumber )
{
  int            i;
  int            status;
  int            sendBufSize = MAX_TCP_SIZE;

/* Create an IP-family socket on which to make the connection */

  clientSocket[serverNumber] = socket(AF_INET, SOCK_STREAM, 0);
  if (clientSocket[serverNumber] < 0) {
      perror("(ipcConnect)=> Error returned from socket() ");

      return( SOCKET_ERROR );
  }


/* Set The System's Buffer Size */
    if (setsockopt(clientSocket[serverNumber],SOL_SOCKET,SO_SNDBUF,
                  (char*) &sendBufSize, sizeof(int)) < 0)
    {
      perror("(ipcConnect)=> Error returned from setsockopt(SO_SNDBUF)");
      return( SOCKET_ERROR );
    }
    if (setsockopt(clientSocket[serverNumber],SOL_SOCKET,SO_RCVBUF,
                  (char*) &sendBufSize, sizeof(int)) < 0)
    {
      perror("(ipcConnect)=> Error returned from setsockopt(SO_RCVBUF)");
      return( SOCKET_ERROR );
    }

/* some other irrelevant code down here */
}

Any help would be appreciated. Thanks so much in advance.....

AquamaN 06-29-2004 03:47 PM

If it says that the protocol is not avaliable it could mean that that specific protocol is not installed on that machine. Have you checked to see that it is?

bonhomme 06-29-2004 06:34 PM

Yah.....I'm guessing that there's a good possibility that it may not be "installed" on the system. Again, I'm using Red Hat 7.2. Is there a possibility that I have to recompile the kernel? I'd really like to avoid that if at all possible. Otherwise, is there a small code segment out there that I can run to give me access? I'm really shooting in the dark here since I'm not very good with socket programming. Any help would be great. Thanks so much.

infamous41md 06-30-2004 12:44 AM

what is MAX_TCP_SIZE set to?

bonhomme 06-30-2004 11:42 AM

It's the following:
Code:

#define MAX_TCP_SIZE = 45*1024

infamous41md 06-30-2004 11:52 AM

hmm that's pretty odd. that value is certainly reasonable. i donno what to tell you. when run this command do u get any results:

sysctl -a | grep wmem_max

that should display the sndbuf max size. i'm wondering if maybe rh7 doesn't support this?


All times are GMT -5. The time now is 06:54 AM.