Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
1 user(s) are online (1 user(s) are browsing Forum)

Members: 0
Guests: 1

more...

Browsing this Thread:   1 Anonymous Users





gethostname Crashes AROS

Joined:
2010/1/8 10:07
Group:
Member
Posts: 1412
Offline
Hi ppl

This code used to display list of ip address'es in h_addr_list[cnt] and now just crashes my aros


----------------------------------
#define HOST_NAME_MAX 1024


int main()
{
gethostname(clientHostName, HOST_NAME_MAX);
printf("%s\n",clientHostName);
struct hostent *thehost = gethostbyname(clientHostName);
printf("%ld\n",(*((unsigned long *) thehost->h_addr_list[0])));
printf("%08lx\n",(*((unsigned long *) thehost->h_addr_list[0])));
return(0);
}
-------------------------------------


download the code to try or please download the executable and run..

also i had to add .exe to GHN to upload here..


Attach file:


c GHN_test.c Size: 1.48 KB; Hits: 99
exe GHN.exe Size: 11.87 KB; Hits: 66

Posted on: 2013/5/28 12:35
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2008/1/7 12:41
From Poland
Group:
Dev
Posts: 2923
Offline
I tried your binary under linux-i386 and it does not crash AROS. It displays this:


.....open okarosbox.arosnet
arosbox.arosnet = 192.168.166.2
44476608
02a6a8c0
*** 'GHN.exe' returned with unfreed signal 0x10000

Posted on: 2013/5/28 21:41
_________________
Krzysztof

"There is no such thing as software for free. If it is not the user who covers the cost of software creation with money, it is the developer who covers this cost with his own free time."

www.aros3d.org
www.twitter.com/ddeadwood
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2010/1/8 10:07
Group:
Member
Posts: 1412
Offline
Quote:

deadwood wrote:
I tried your binary under linux-i386 and it does not crash AROS. It displays this:


.....open okarosbox.arosnet
arosbox.arosnet = 192.168.166.2
44476608
02a6a8c0
*** 'GHN.exe' returned with unfreed signal 0x10000


Thats what i used to get but now just crash (Sorry i have used word crash which is not true just does not give what i want as output and does NOT crash).

Quote:

44476608
02a6a8c0



They are loopback addresses in reverse order and btw i am native..



Attach file:



jpg  ghn.jpg (74.00 KB)
1528_51a5e41bcb62c.jpg 1024X600 px

jpg  ghn2.jpg (78.92 KB)
1528_51a5e42787481.jpg 1024X600 px

Posted on: 2013/5/29 4:15

Edited by serk118uk on 2013/5/29 4:59:49
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2009/10/13 1:12
From Poland - Italy
Group:
Member
Posts: 467
Offline
Hi,

trying your code on i386 native RTL8139 NIC, seems to me that gethostbyname() works, but not with "arosbox.arosnet" hostname.

If I use google.com for example, all is fine:

struct hostent *thehost = gethostbyname("www.google.com");

arosbox.arosnet is set both in Prefs/Network and in AROSTCP/db/netdb-myhost, but for example in my case, netdb-myhost has a wrong IP address.

And you can't resolve it neither with "ping" nor "resolve" commands from AROSTCP/C.

Maybe Pavel is reading and can shed some light here, he's the one who ported AROSTCP, if I remember correctly.


-- LuKe





Posted on: 2013/5/29 8:12
_________________
"I'm told they let DiskDoctor decide its own fate. They put the sources on a floppy, then ran DiskDoctor on it. The floppy was trashed, so was DiskDoctor." --Dave Haynie
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2005/2/1 19:32
Group:
Member
Posts: 498
Offline
hi,

having problems with gethostbyname() here... I'm probably doing something wrong.

[update, a bit later:]


ok, now gethostbyname() works, after adding struct SocketBase and calls to OpenLibrary() and CloseLibrary() (like serk does in his GHN_test.c), and #include <exec.h> (avoids some warning).


which confuses me, because...

a) i see some example code that does OpenLibrary(), and other that doesn't
(e.g. here, without OpenLibrary(): https://en.wikibooks.org/wiki/Aros/Dev ... rld.22_example_sourcecode )

b) i do not #include <proto/bsdsocket.h> (like serk does in his GHN_test.c)

c) i remember previously getting some compiler error like "error: redefinition of SocketBase, previous definition was in ...bsdsocket..." (sorry, cannot remeber precisely, and cannot reproduce right now) _WITHOUT_ any #include <...bsdsocket...> (but with #include <sys/socket.h>, <netinet/in/h>, <netdb.h>, <arpa/inet.h>)

that leads me to the conclusion that there IS some automatism going on regarding bsdsocket(.library? .h?) stuff, but I still have to OpenLibrary(), define SocketBase, ...?

what's actually happening?
can someone clarify?

Posted on: 7/12 5:35
_________________
http://amigaalive.de
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2004/10/30 17:13
From Ireland
Group:
Member
Posts: 2619
Offline
Are you asking about opening libraries in general, or just bsdsocket.library? The example you linked to uses some libraries without manually opening them, but not bsdsocket AFAICT. Yes, there are some core libraries that can be automatically opened, but I don't have a list of them handy.

AFAIK you should always include proto/bsdsocket.h if you're going to use functions from that library, but it may have been made optional to make porting of Linux code easier (I'm just guessing). I would include it if doing so isn't causing problems.

Posted on: 7/14 11:08
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2005/2/1 19:32
Group:
Member
Posts: 498
Offline
Quote:
...there are some core libraries that can be automatically opened... AFAIK you should... may have been made optional... I'm just guessing... include it if doing so isn't causing problems...


Thanks (seriously!)

To answer your question, and/or just to make my point clear:

I don't know what library I'm asking about. Bsdsocket? Any other? You tell me...

Which core libraries? "Can" be opened, or "are" opened? Why "should", not "have to", or "dont"? ...

See my point? We're talking about computers here. There's no "may" or "should", computers don't judge. (I know I'm simplifying here.)

You may have seen some other of my posts about "GetRastPort(screen)" function, and how/when to use it. Then someone tells me I can also use Screen->RastPort. Well, then why don't we drop the whole API and use structures and pointers directly? No, I "can't" use Screen->RastPort, that's simply wrong. I "have to" use GetRastPort(), that's the intended way of using the API. (And there's good reasons for sticking to a defined API.)

Don't get me wrong, I'm not ranting here - all I'm trying to say is:
a) AROS is a mess
b) Any API has to be clearly structured, and used accordingly, there should be no room for interpretation, e.g. all libraries should be handled equally, please, dear developers!

Of course I'm aware of the fact that you and everyone else is in the same situation as I am: AROS is a moving, wobbling target.
I'm not criticizing your guessing! I just think AROS shouldn't be a guessing game.

Once again, to make that perfectly clear:
- I probably know less about AROS than everyone else around here!
- No ranting here, just trying to help improve the situation!
- I'm a big fan of AROS and Amiga!
- Thanks for your (and everyone's) reply (replies)! (you DID help me! again!)
- Thanks everyone for the amazing work you're doing on AROS!

Posted on: 7/14 13:04
_________________
http://amigaalive.de
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2016/8/16 0:09
Group:
Member
Posts: 267
Offline
Quote:

roMancer wrote:

Which core libraries? "Can" be opened, or "are" opened? Why "should", not "have to", or "dont"? ...

See my point? We're talking about computers here. There's no "may" or "should", computers don't judge. (I know I'm simplifying here.)

That's why i use Pascal.

All libraries are automatically opened by inclusion of their respective header file (that is if it wasn't already opened by the RTL to begin with)

See, my point ? ;-p

It depends on the compiler, although for AROS there is a bit more to it then only the compiler. Such knowledge comes with time, my friend

Quote:

Don't get me wrong, I'm not ranting here - all I'm trying to say is:

In an ideal world, perhaps yes.

Never have i seen an API/SDK that is completely documented, free of errors, and some 'exposed' functionality sometimes isn't even stable. (hello m$ with the big bucks ... or was it bugs ).

Welcome (back) roMancer !

Posted on: 7/14 14:38
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2004/10/30 17:13
From Ireland
Group:
Member
Posts: 2619
Offline
@roMancer

Yes, I was aware when writing my previous post that it was vague, and therefore not as helpful as it could be, but I hoped I could point you in the right general direction. I'm frustrated by the lack of AROS documentation too, but it's possible the issue discussed here is documented somewhere and I'm just ignorant of it.

However, it isn't unusual in programming generally for there to be things that "may" be done but don't have to be, e.g. a C function without a return value can end with a return statement, but doesn't have to; specifying the size when defining a C string is optional.

Posted on: 7/14 16:07
Transfer the post to other applications Transfer


Re: gethostname Crashes AROS

Joined:
2005/2/1 19:32
Group:
Member
Posts: 498
Offline
sure, nooo, yes, of course, I know, nothing's bugfree, and yeah you did point me to the right direction, ...

...hugs & beer for everyone

Posted on: 7/14 17:42
_________________
http://amigaalive.de
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4340
2 magorium
magorium
4095
3 phoenixkonsole
phoenixkonsole
3887
4 nikolaos
nikolaos
3677
5 deadwood
deadwood
2923
6 ncafferkey
ncafferkey
2619
7 mazze
mazze
2211
8 clusteruk
clusteruk
2091
9 Kalamatee
Kalamatee
2023
10 damocles
damocles
1789
© 2004-2017 AROS Exec