Hi All,
int bind(int SOCKFD, struct sockaddr *MYADDR, int ADDRLEN);
In the above system call, the third argument is the length of socket address structure.
My question is why we need third argument? since we are passing second parameter as pointer to socket address structure, so it can calculate itself the length of the structure.
Thanks,
Manjunath
2 1942 Banfa 9,065
Recognized Expert Moderator Expert
No you can not calculate the length of anything based on a pointer to it. In particular the sockaddr structure contents may be different depending on the type of network address being supplied, e.g. IVv4 or IPv6 to name two.
It you google struct sockaddr you will find that this is a generic pointer to a family of structures which are all different specifying network addresses in different protocols.
The size parameter therefore lets the function use this pointer while ensuring that it does not cause undefined behaviour by accessing out of bounds data.
Thanks a lot, The answer make my confusion clear.
Thanks,
Manjunath
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it...
|
by: William S. Perrin |
last post by:
I'm a python rookie, anyone have and suggestions to streamline this
function? Thanks in advance.....
def getdata(myurl):
sock = urllib.urlopen(myurl)
xmlSrc = sock.read()
sock.close()
xmldoc = minidom.parseString(xmlSrc)
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: lester |
last post by:
a pre-beginner's question:
what is the pros and cons of .net, compared to ++
I am wondering what can I get if I continue to learn C# after I have learned
C --> C++ --> C# ??
I think there must be many know the answer here.
thanks
|
by: Fernando Cacciola |
last post by:
I'm puzzled,
Why and how _exactly_ is this:
void Foo<T>(T v ) where T : Interface/Value/Class/class
any better than this
void Foo( Interface/Value/Class/object v )
| |
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic paper written on this
subject.
On the Expressive Power of Programming Languages, by Matthias
Felleisen, 1990....
|
by: Peter Lee |
last post by:
what's the correct behaver about the following code ? ( C++
standard )
I got a very strange result....
class MyClass
{
public:
MyClass(const char* p)
{
printf("ctor p=%s\n", p);
|
by: zslevi |
last post by:
I'm reading this page: http://www.ps.uni-sb.de/~duchier/python/continuations.html
and I've found a strange usage of lambda:
####################
Now, CPS would transform the baz function above into:
def baz(x,y,c):
mul(2,x,lambda v,y=y,c=c: add(v,y,c))
###################
|
by: lorlarz |
last post by:
In the code sample below, how are arguments a legitimate
argument to Array.slice?
Function.prototype.bind = function(){
var fn = this, args = Array.prototype.slice.call(arguments), object =
args.shift();
return function(){
return fn.apply(object,
args.concat(Array.prototype.slice.call(arguments)));
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |