errno 68 - EADDRNOTAVAIL on all ports

errno 68 - EADDRNOTAVAIL on all ports

Post by vide.. » Fri, 24 Mar 2000 04:00:00



Hello,

This is my program :

int sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

sockaddr_in a;

a.sin_family=AF_INET;
a,sin_port=htons(atoi(argv[1]));
a.sin_addr.s_addr=inet_addr("127.0.0.1");

if(bind(sock,(sockaddr*)&a,sizeof(sockaddr_in))<0)
cout<<"bind failed,errno="<<errno<<endl;

It generates "bind failed,errno=68" no matter what port I try to bind
to. Someone in the unix.programmer group suggested using
setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,...) - I tried this and it's all
the same.

I don't understand why would the bind fail on all ports ? Has anyone
seen anything like this ? I would appreciate your help.

Thank you,

Martin

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

errno 68 - EADDRNOTAVAIL on all ports

Post by F. Michael Or » Sat, 25 Mar 2000 04:00:00



> Hello,

> This is my program :

> int sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

> sockaddr_in a;

> a.sin_family=AF_INET;
> a,sin_port=htons(atoi(argv[1]));
> a.sin_addr.s_addr=inet_addr("127.0.0.1");

> if(bind(sock,(sockaddr*)&a,sizeof(sockaddr_in))<0)
> cout<<"bind failed,errno="<<errno<<endl;

> It generates "bind failed,errno=68" no matter what port I try to bind
> to. Someone in the unix.programmer group suggested using
> setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,...) - I tried this and it's all
> the same.

> I don't understand why would the bind fail on all ports ? Has anyone
> seen anything like this ? I would appreciate your help.

Two things I see.  First, you should check the return from the socket()
call; make sure it isn't returning -1 and setting errno because of
something it doesn't like.  Secondly, along those same lines, most of
the sockets documentation I have, which I have used to write my
programs, recommend leaving the third parameter of the socket() call to
0.  I know that it says it will default to TCP for STREAM type sockets,
but it might be worth a shot.

--

F. Michael Orr
Sr. Systems Engineer
Norfolk Public Schools, Norfolk, VA, USA

 
 
 

errno 68 - EADDRNOTAVAIL on all ports

Post by Bernard Dhoogh » Wed, 29 Mar 2000 04:00:00


There is a 8 byte part called sin_zero in sockaddr_in that is not used by
the application itself but that should be initialized to zero:

  bzero((char *) &a,sizeof(a))

  or

  bzero(a.sin_port,8);

Bernard Dhooghe .


> Hello,

> This is my program :

> int sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

> sockaddr_in a;

> a.sin_family=AF_INET;
> a,sin_port=htons(atoi(argv[1]));
> a.sin_addr.s_addr=inet_addr("127.0.0.1");

> if(bind(sock,(sockaddr*)&a,sizeof(sockaddr_in))<0)
> cout<<"bind failed,errno="<<errno<<endl;

> It generates "bind failed,errno=68" no matter what port I try to bind
> to. Someone in the unix.programmer group suggested using
> setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,...) - I tried this and it's all
> the same.

> I don't understand why would the bind fail on all ports ? Has anyone
> seen anything like this ? I would appreciate your help.

> Thank you,

> Martin

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

1. socket errno 68

I'm trying to bind to a socket and it is failing with socket errno 68.  I've
seen the following in a previous post on this newsgroup:
----------------------------------------
There is a 8 byte part called sin_zero in sockaddr_in that is not used by
the application itself but that should be initialized to zero:

  bzero((char *) &a,sizeof(a))

  or

  bzero(a.sin_port,8);

----------------------------------------
This worked great.  But I don't know why it is suddenly necessary to
initialize this sin_zero variable.  Basically I am required to detail my
fix, so I was wondering if anyone could explain why I was able to use this
socket code fine for most socket binds, but then for some reason when I
tried to do the 6th socket bind using my application, it failed.  Could
someone tell me why it is necessary to intialize sin_zero in some cases, but
not in all.

Thanks,
Novice

2. Help setting up sharing of files/printers on RedHat 7.2

3. HVD SCSI Terminator 68 pin with a LVD - SE device 68 pin??

4. NT printer from RH7 - NT thinks it's Unix?

5. Is Sun "unipack 8mm tape 68/68" an EXABYTE?

6. Question: select() & zero-byte strings

7. (more) Is Sun "unipack 8mm tape 68/68" an EXABYTE?

8. Help:IRIX installation has special problem?

9. lpd dies with errno 99 (EADDRNOTAVAIL)

10. udp port 68 scans?

11. DHCP problems port 67 & 68

12. Why does dhclient bind to port 68?