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

bind() problem...

72 views
Skip to first unread message

Joachim Pluschke

unread,
May 10, 2001, 12:52:07 PM5/10/01
to
vxworks 5.4, Tronado 2, PPC860 target & bsp

Hi ALL,


I'm trying to make a TCP connection running....
but around the bind() call I'm not clear about what's happening...
To exclude an hints by "own" software i took the
tcpServer.c, tcpClient.c, tcpExample.h from the vx-onlinemanual.

When I set
serverAddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
or
serverAddr.sin_addr.s_addr = htonl (INADDR_ANY);
the tcpserver started up (i.e. the bind()-call was ok)
and in case of INADDR_ANY the client - server communication worked
(exchanging some strings).

BUT HOW TO PUT IN A SPECIFIC LOCAL IP THAT WORKS????

I took a look at byte-ordering , the servers IP interface (ifShow()) was
set as wanted.
Trying to feed in a specific IP (hex) in the according "struct
sockaddr_in" field like

serverAddr.sin_addr.s_addr = htonl ((u_long)(0xAC220107));/*172.16.1.7*/

_always_ caused the bind-error "0x31" ....
(EADDRNOTAVAIL 49 /* Can't assign requested address */)


ANY IDEAS why bind fails using a specific IP (servers' IP)????


I found a lot of articles around bind() and sockets in the
news-archives, but i didn't get the reason for this behaviour of bind().
Of course, using INADDR_ANY is not the solution.
(additional info: the target boots over network properly and can be
accessed with ftp!)


thanks in advance,
joachim


--

=====================================================
Gebrüder Stoye GmbH
department: traffic control systems
name: Joachim Pluschke
adr: Longericher Strasse 177
city: Cologne, Germany
zip: 50739
phone: ++49/221/1707013
fax: ++49/221/1707010
mailto: j.plu...@stoye.de
www: http://www.stoye.de
=====================================================

Eric Lesch

unread,
May 10, 2001, 4:39:34 PM5/10/01
to
Hi Joachim,

Try using inet_addr("172.16.1.7") to avoid errors.

0xAC220107 = 172.34.1.7
Is that your problem?

Hope this helps,
Eric Lesch

Urban Lindberg

unread,
May 11, 2001, 4:40:32 AM5/11/01
to
Hi

Using inet_addr("172.16.1.7") returns 0xAC100107 not 0xAC220107, which
one is correct the comment or the code?

HTH
Urban

Joachim Pluschke

unread,
May 11, 2001, 7:05:45 AM5/11/01
to
thanks Eric!

Yes, now the sample-code bind() works.
- I should have typed in the correct IP and not rely on others
hex-values...

...sometimes problems seem to be confusing
but they're no problems... ;)


regards
Joachim


Eric Lesch schrieb:

0 new messages