Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bind()/sobind() failure with errno:49 - help please

759 views
Skip to first unread message

Babu Yama

unread,
Sep 28, 2001, 5:58:12 PM9/28/01
to
Hi,
I am using the following tcpServer.c code form windriver network programmer's
guide. The bind call is failing with errno:49
(#define EADDRNOTAVAIL 49 /* Can't assign requested address */).
This errono:49 is being returned by sobind() call (code at the bottom) which is
called by bind().

I tried INADDR_ANY inaddition to my IpAddr, and tried port numbers of 5001,
2455, etc. with the same errno.

My interface is up and running. ifshow() is proper. I am able to ping my IPAddr.

What could be wrong? Any help to solve the problem ?

Thanks,
Babu


STATUS tcpServer (void)
{
struct sockaddr_in serverAddr; /* server's socket address */
struct sockaddr_in clientAddr; /* client's socket address */
int sockAddrSize; /* size of socket address structure */
int sFd; /* socket file descriptor */
int newFd; /* socket descriptor from accept */
int ix = 0; /* counter for work task names */
char workName[16]; /* name of work task */
unsigned long hAddr;
unsigned long nAddr;

/* set up the local address */
sockAddrSize = sizeof (struct sockaddr_in);
bzero ((char *) &serverAddr, sockAddrSize);
serverAddr.sin_family = AF_INET;
serverAddr.sin_len = (u_char) sockAddrSize;
serverAddr.sin_port = htons (SERVER_PORT_NUM);
/* for some reason getting cann't assign this addr errorno:49 LATER */
/* serverAddr.sin_addr.s_addr = htonl (INADDR_ANY); */
hAddr = inet_addr(tcpServerIpAddr);
nAddr = htonl(hAddr);
serverAddr.sin_addr.s_addr = nAddr;


/* create a TCP-based socket */


if ((sFd = socket (AF_INET, SOCK_STREAM, 0)) == ERROR)
{
perror ("socket");
return (ERROR);
}


/* bind socket to local address */
if (bind (sFd, (struct sockaddr *) &serverAddr, sockAddrSize) == ERROR)
{
perror ("bind");
close (sFd);
return (ERROR);
}

int
sobind(so, nam)
struct socket *so;
struct mbuf *nam;
{
int s = splnet();
int error;

error =
(*so->so_proto->pr_usrreq)(so, PRU_BIND,
(struct mbuf *)0, nam, (struct mbuf *)0);
splx(s);
return (error);
}

Patrick@Roadrunner

unread,
Sep 28, 2001, 10:02:21 PM9/28/01
to
I seem to remember some notes in WRS support site about this.
Does this happen the first time you run the tcpServer after bootup or
subsequent times. If the first time is ok and all subsequent times are not
then the socket is probably not getting closed properly when you exit the
server.

Otherwise do a search for socketOption REUSE_ADDR, and you may find the
answer.


Regards,
Patrick
"Babu Yama" <babu...@lucent.com> wrote in message
news:3BB4F274...@lucent.com...

0 new messages