LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-29-2004, 12:12 PM   #1
bonhomme
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Rep: Reputation: 0
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.....
 
Old 06-29-2004, 03:47 PM   #2
AquamaN
Member
 
Registered: Oct 2002
Location: Ohio, USA
Distribution: OS X 10.4.8, Ubuntu 6.10
Posts: 146

Rep: Reputation: 15
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?
 
Old 06-29-2004, 06:34 PM   #3
bonhomme
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Original Poster
Rep: Reputation: 0
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.
 
Old 06-30-2004, 12:44 AM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
what is MAX_TCP_SIZE set to?
 
Old 06-30-2004, 11:42 AM   #5
bonhomme
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Original Poster
Rep: Reputation: 0
It's the following:
Code:
#define MAX_TCP_SIZE = 45*1024
 
Old 06-30-2004, 11:52 AM   #6
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
socket: Address family not supported by protocol utumno Linux - Networking 0 12-05-2004 03:19 AM
SSH - socket: Address family not supported by protocol SkyLinePL Linux - Networking 4 09-24-2004 12:03 AM
refb protocol socket Noems Programming 9 08-16-2004 12:15 PM
GVRP pdu and protocol ID using RAW socket hemantrath Linux - Networking 0 04-25-2004 09:06 AM
Warning: failed to install socket filter: Protocol not available ixion Linux - Networking 0 08-12-2003 09:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration