Are there any standard posix c functions to convert a subnet string in dot notation to its slash notation int value? For example something like:
inet_atoi("255.255.255.0") returning 24
Are there any standard posix c functions to convert a subnet string in dot notation to its slash notation int value? For example something like:
inet_atoi("255.255.255.0") returning 24
Why don't you just include sockets or winsock and use the functions it gives?
Oh, a lot of reason. But mostly time. I don't want to spend days reading through text just to see if such a function exists. I ended up writing my own, but am still curious to know if such a function exists, and if it does, what is it called?
It's really not that tedious...
Winsock Functions (Windows)
There ya go, all on one page.
1) From that, it looks lilke the answer is no. That function doesn't exist. So why ask me to look for something that isn't there.
2) winsock = posix now?
Woah! Take it easy with that attitude. Expecting anybody to hold the full contents of the sockets API in their head and just spit out what you want is just plain silly. You even copped to being too lazy to look it up ("I don't want to spend days...wah wah wah"). I'm sure you didn't expect Tater to actually read through the sockets API docs for you and give you an answer. He merely gave you a comprehensive list of sockets functions for you to check, doing the Google search you should have done in the first place. Besides, I'm sure the "days" you spent looking at the documentation (which was really only 50 minutes) didn't hurt you any. Now you know the answer to your question, and probably learned something else along the way.
No, but they are extremely similar, since both were based on Berkeley's BSD sockets implementation. Most code is interchangeable, and that was probably the first doc that Tater could get a hold of. Again, try being a little more polite to those who are trying to help you, and realize that just because he didn't link you to a page with a giant flashing sign saying "Look homer_3! The exact function you want is right here!", doesn't mean that you couldn't have found functions to help you roll your own by putting in a little effort.2) winsock = posix now?
Do you really think I didn't do a google search before asking? I didn't find anything, so I posted here on the chance that someone might know. Perhaps someone else that visits these forums had a similar problem. If they don't know, fine. But I don't expect "why don't you read the entire C socket API LOL!"
There was no indication that you tried a Google search in any of your posts (until now, but it's too late), and in your the second post, you basically said "I'm too lazy to read docs". That doesn't go over well with anybody here. Actually, it's a pretty good way to not get helped. This is how the conversation reads:
you: Is there a function for x?
Tater: Try checking the following APIs...
you: I'm lazy, can't you find the answer for me.
Tater: Here's a link to a list of all the functions in said API. See if what you need is on that list.
you: !%$@$ Wah, wah, wah! Why are you so mean!?!
And nobody ever told you to read the whole API, just a brief summary of the available functions. Basically, you could have eliminated 90% of those functions by reading the name and/or brief descriptions, which should have taken all of a minute or two. Then, maybe you had to read a little more into 4 or 5 of them to see if they perhaps did what you want. Total time required? 15 minutes max. BFD. We're not here to RTFM on your behalf. If you don't tell us you did your research and read the docs and still can't find it, we assume you're lazy. You'd be surprised at just how many people come to us with "can you write a program for me" questions...naturally, we're a bit jaded.