• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Search | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

C++ developers/socket programming

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
hush
Just Arrived
Just Arrived


Joined: 04 Nov 2005
Posts: 8
Location: London

Offline

PostPosted: Fri Jan 13, 2006 2:01 pm    Post subject: C++ developers/socket programming Reply with quote

I was looking at the job market and noticed that quite a few (sorry I canít be more precise) employers requested that C++ developers had knowledge of TCP/IP and other aspects of networking, why is this?

I would be grateful if anyone could supply a link that describes the function of socket programming (a beginnerís guide toÖ). Thanks in advance.

hush
Back to top
View user's profile Send private message
hugo
Forum Fanatic
Forum Fanatic


Joined: 14 Jun 2003
Posts: 16777215
Location: Netherlands, Europe

Offline

PostPosted: Fri Jan 13, 2006 2:56 pm    Post subject: Re: C++ developers/socket programming Reply with quote

hush wrote:
I was looking at the job market and noticed that quite a few (sorry I canít be more precise) employers requested that C++ developers had knowledge of TCP/IP and other aspects of networking, why is this?

This is probably because the jobs are network-related. Other than that I cannot think of a reason why they would require this.

Then again, in todays world, all machines seem to be network-connected so it is knowledge you almost cannot do without.

hush wrote:
I would be grateful if anyone could supply a link that describes the function of socket programming (a beginnerís guide toÖ). Thanks in advance.

Here is a link to one of the most famous tutorials on the internet. Smile

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

Good luck.
Back to top
View user's profile Send private message
CabTRR
Just Arrived
Just Arrived


Joined: 12 Jan 2006
Posts: 0
Location: Istanbul/Turkey

Offline

PostPosted: Fri Jan 13, 2006 8:06 pm    Post subject: socket programming Reply with quote

because of that only a computer doesn't have any meaning because no longer computers live on one's one, so they have to connect another computer.
So you have to know socket programming to write socket programs. To write socket program you have to know information about networking: TCP/IP, and other protocols..
Back to top
View user's profile Send private message Send e-mail MSN Messenger
hush
Just Arrived
Just Arrived


Joined: 04 Nov 2005
Posts: 8
Location: London

Offline

PostPosted: Sun Jan 15, 2006 5:59 pm    Post subject: Reply with quote

thanks for the link there hugo Very Happy .

a C question:

is using var+=1 more efficient then var=var+1? why/why not?
which method is used more by pro coders/armature gurus?

hush
Back to top
View user's profile Send private message
capi
SF Senior Mod
SF Senior Mod


Joined: 21 Sep 2003
Posts: 16777097
Location: Portugal

Offline

PostPosted: Sun Jan 15, 2006 6:59 pm    Post subject: Reply with quote

hush wrote:
a C question:

is using var+=1 more efficient then var=var+1? why/why not?
which method is used more by pro coders/armature gurus?

Short answer: in theory, yes. It has the potential to be more efficient. However, a decent optimizing compiler should optimize the second case to the same code as the first one.

Long answer: when you say var+=1, you are telling the compiler "increment the variable by one". There is no redundancy. When you say var=var+1, what you are literally saying is "calculate the value of this variable, add one to it, then store the result in the variable again". There is a semantic difference there.

Most CPU architectures, and the x86 in particular, have a way of adding to a variable in-place (that is, to add to whatever is there) with a single instruction. So, your first form can be directly implemented with a single instruction, even without optimization being involved. The second form, however, is a generic assignment. The compiler will first focus on calculating the value of the expression on the right (meaning it will have to copy the value of var to a temporary variable before adding to it, because it doesn't want to spoil the original value of var), then once it has the result it will move that into the left part of the assignment (thus moving the value into var). This is a redundancy, of course.

A properly optimizing compiler will likely notice the redundancy and issue the direct code in the first place (directly altering var in-place). However, one should not rely on compiler optimization to improve one's own code. As I usually say in these cases: why not say what you mean?

In general, when choosing between a more general form, and a particular case that's been tailored to serve a specific need, all other things being equal one should opt to use the particular case. It is more likely that it will be more optimized for that specific need, as it was made precisely for that. Of course the general case may get optimized as well once the compiler realizes it's really a particular case, but why rely on optimization when you can just be specific about what you want?

Incidentally, when it comes to incrementing a variable by one, as in your example var+=1, there is an instruction that is even more specific: var++ (or ++var). The ++ operator is meant specifically to increment the variable by one, as opposed to the more general += one, which is to increment by any given value. This makes a difference in architectures such as the x86 where there is a specific instruction to increment a register or memory by one (the inc assembly instruction), which is more specific and optimized than the instruction to increment by a generic value (the add instruction). Of course, again, a good optimizing compiler will notice the particular case anyway and use the most efficient instruction.



As a side note, not regarding your question directly, it is for these same reasons that I generally prefer using for(;;) for infinite loops, rather than while(1). Although they may both have the same effect, what you are literally saying when you say for(;;) is "repeat forever" (as there is no end condition), yet when you say while(1) you are actually saying "repeat while 1 is different from 0". Again, there is a semantic difference here. Although it is obvious to any human being that the second form will always be true (and thus can be optimized to an infinite loop), to a machine nothing is obvious. Of course, a decent optimizing compiler will recognize that 1 will always be different from 0 and not bother with generating code to compare 1 with 0 on every iteration of the loop. However, this is a prerrogative of the compiler; it is not what you are literally telling it to do. Always better to say what you mean.
Back to top
View user's profile Send private message
hush
Just Arrived
Just Arrived


Joined: 04 Nov 2005
Posts: 8
Location: London

Offline

PostPosted: Sun Jan 15, 2006 7:38 pm    Post subject: Reply with quote

An excellent reply there capi (a reply++), thanks a lot Very Happy .
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Area

Log in | Register