ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am working on a small project in Linux, written in the C language, that allows communication to and from a server. So far I have my concept in mind, and source code close to flawless. Though, I have a small problem. To reduce the size of code used in main, I created a structure to allow the handles of clients, sockets, and other information store in different areas. Though, to make my job easier, I want to pass the address of a sockaddr_in and access its members inside a function.
Though, when I do, it gives an error as the following: "request for member 'sin_family' in something not a structure or union"
No problem. A couple of questions, out of curiousity:
1. What are you working on, if I can ask?
2. Which of the two methods do you choose to use? I generally use the second just because it looks cleaner, though the first is more explicit.
I just started learning UNIX Network Programming a few months ago, say, about 2. I have been programming in the C language for a good 4 years. Though, sockets, and other functions are kind of new to me. I occasionally have a problem in my source code, as trivial as this one might I add. To answer this question, I'm just trying to make a test echo server. Though, I am adding a hash table to store and organize all the clients that connect. So I can look them up, remove them, add them, and other fun stuff. It's just to test my C ability.
Quote:
2. Which of the two methods do you choose to use? I generally use the second just because it looks cleaner, though the first is more explicit.
I chose the first, as of now. Since I am passing a few other pointers, for instance integers, I wanted to keep the dereference style the same. Since none of the variables I pass are truely pointers, but rather memory addresses to local variables, I didn't want to get into a habit of using the pointer to struct shorthand (->) in this type of situation. I admit, the second method looks cleaner, though I am looking for more of an explict look.
I've been working on this project for some time now, though now I am developing it under the Linux environment. I've spent a while allowing executable options. And also able to read in a configuration file and parse it. Though, I spent the last few hours cleaning up all the compiler warnings and errors for GCC 3.4.3 since it's a bit more picky than usual, esp. with the -Wall, -pedantic, -ansi, and -std=c89 flags. Though, I managed to make the build perfectly clean. I am considering releasing the source code, but first I need to figure out why all connections never make it through to the server. No matter how many clients I write.
Hope this answers your questions,
- Stack Overflow
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.