LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2013, 06:18 PM   #1
HalfMadDad
Member
 
Registered: Jun 2010
Location: Canada
Distribution: Slackware, systemd-garbage
Posts: 143

Rep: Reputation: 9
help understanding configuration structs


Hi Everyone

I am doing some socket and serial programming.

I can follow along with things but there is something I just don't understand and it's fundamental.

So with serial programming on posix we include termios.h and there are various struct fields that can be set to different values.

Once these are all set up, the port itself is configured for use. I assume that other applications could actually access the port using the same parameters(assuming nothing is locked). I am assuming this is how the command stty works.

The thing I don't get is that if I am including some struct via an include file, am I not using a copy of this code. It seems like the changes are global though. Does the struct have function pointers in it that make the changes global.

I am not very far along with socket programming but is this the same situation, function pointers acting on the struct settings to make changes globally ?

Thanks for reading-Patrick
 
Old 07-31-2013, 07:13 PM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
It would help if you posted a short (socket) code snippet
 
Old 07-31-2013, 08:54 PM   #3
HalfMadDad
Member
 
Registered: Jun 2010
Location: Canada
Distribution: Slackware, systemd-garbage
Posts: 143

Original Poster
Rep: Reputation: 9
Hi Meson

My own code is snippets of trash I am too embarressed to post right now.

Here is a link to a wikipedia book:

http://en.wikibooks.org/wiki/Serial_Programming/termios

Most of this page deals with termios but this section clearly does:

Basic Configuration of a Serial Interface

Thanks
 
Old 07-31-2013, 09:13 PM   #4
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
I was after snippets of socket programming that's confusing you.
 
Old 07-31-2013, 10:08 PM   #5
HalfMadDad
Member
 
Registered: Jun 2010
Location: Canada
Distribution: Slackware, systemd-garbage
Posts: 143

Original Poster
Rep: Reputation: 9
Hi Meson

Sorry I am not being very helpful. I don't have anything to show.

I have been working through this book:

http://beej.us/guide/bgnet/

socket programming seems to be similar in that we are working with system structs but I have even less experience then serial.
 
Old 08-04-2013, 07:51 AM   #6
HalfMadDad
Member
 
Registered: Jun 2010
Location: Canada
Distribution: Slackware, systemd-garbage
Posts: 143

Original Poster
Rep: Reputation: 9
Hi Everyone

I think I can answer my own question now. I just wanted to post back in case someone finds this later.

If I have a serial port configuration struct in memory and I have a bunch of functions that manipulate it, what good is that. Well it is if you have:

tcgetattr() to propagate the struct with what is already configured at the port beforehand and

tcsetattr() to apply all the settings from the in memory struct to the OS.

-Patrick
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sendmail basic understanding of operation needed for configuration burkecabaniss Linux - Newbie 5 05-16-2013 03:24 AM
help with structs and pointers in C++ darkangel29 Programming 4 05-25-2011 04:15 AM
Understanding Delay Pool Configuration (Squid) carl0ski Linux - Server 0 04-20-2007 01:00 AM
static structs? simbo Programming 3 02-05-2004 04:00 AM
Self referential structs in C? MadCactus Programming 14 01-28-2004 05:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration