Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* help: EADDRNOTAVAIL after bind()
@ 1995-02-21 13:13 Geert Coelmont
  1995-02-24 12:54 ` Geert Coelmont
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Coelmont @ 1995-02-21 13:13 UTC (permalink / raw)


Hi there,

I have a problem that seems to occur only on DEC alpha, not on HP-UX,
SunOS, Sinix, or even OS/2, so i humbly think it's not the source ;-)
Could anybody help me with this.
This source extract (edited to keep it reasonably short) should
allocate a socket and bind it to a ip-address. Not so on our dec
machine, we get errno EADDRNOTAVAIL (49)
on the bind call. What are we doing wrong here, what can be the 
cause of EADDRNOTAVAIL ?

if possible, send replies to    gc@tyana.denkart.be
thanks in advance for your time and help

geert coelmont,
denkart n.v.



call:  build_socket(<servicename>, 0, 1, 1);

int
build_socket (char *service_name, unsigned short port_nbr, int use_host, int max_listen)
  {
  int                   optval;
  int                   socket_nbr = -1;
  struct hostent     *  host;
  struct servent     *  serv;
  struct sockaddr_in    sin;
  struct utsname        u_name;
  char                  buffer[sizeof u_name.nodename + 1;

  if ( (socket_nbr = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    return -1;
  printf("socket number: %d\n", socket_nbr);
  optval = 1;
  setsockopt(socket_nbr, SOL_SOCKET, SO_REUSEADDR,(void*)&optval,sizeof optval);
  memset((void*)&sin, 0 , sizeof sin);
  sin.sin_family      = AF_INET;
  if (use_host)
    {
    if (uname(&u_name) == -1)
      {
      return -1;
      }
    else
      {
      memcpy(buffer, u_name.nodename, sizeof u_name.nodename);
      if ( (host = gethostbyname(buffer)) == NULL )
        return -1;
      }
    memcpy((char*)&sin.sin_addr, host->h_addr, host->h_length);
    }
  else
    sin.sin_addr.s_addr = INADDR_ANY ;
  if (service_name)
    {
    printf("getting main socket: %s\n", service_name);
    if ( (serv = getservbyname(service_name, "tcp")) == NULL )
      return -1;
    sin.sin_port = htons(serv->s_port);
    printf("service info: %s %s %d\n", serv->s_name,serv->s_proto,sin.sin_port);
    }
  else
    sin.sin_port        = port_nbr;
  if ( bind(socket_nbr, (void *)&sin, sizeof sin) == -1)
    return -1;
  printf("bind to address: %s\n", inet_ntoa(sin.sin_addr));

  if (listen(socket_nbr, max_listen ) == -1)
    return -1;

  printf("listening\n");
  return socket_nbr;
  }



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: help: EADDRNOTAVAIL after bind()
  1995-02-21 13:13 help: EADDRNOTAVAIL after bind() Geert Coelmont
@ 1995-02-24 12:54 ` Geert Coelmont
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Coelmont @ 1995-02-24 12:54 UTC (permalink / raw)


Last week, I <gc@tyana.denkart.be> wrote:

> Hi there,
> 
> I have a problem that seems to occur only on DEC alpha, not on HP-UX,
> SunOS, Sinix, or even OS/2, so i humbly think it's not the source ;-)
> Could anybody help me with this.
> This source extract (edited to keep it reasonably short) should
> allocate a socket and bind it to a ip-address. Not so on our dec
> machine, we get errno EADDRNOTAVAIL (49)
> on the bind call. What are we doing wrong here, what can be the 
> cause of EADDRNOTAVAIL ?
> 
> if possible, send replies to    gc@tyana.denkart.be
> thanks in advance for your time and help
> 
> geert coelmont,
> denkart n.v.

Is nobody reading this or does nobody know about this ?
I'm really desperate ;-(

geert coelmont
                                                          
                                                        
                                                             
                                                               
                                                                
                                                              
                                                             
                                                                
                                                               



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-02-24 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-02-21 13:13 help: EADDRNOTAVAIL after bind() Geert Coelmont
1995-02-24 12:54 ` Geert Coelmont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox