![]() |
Figure 1 – Architecture ofSetting Connection-oriented Socket |
![]() |
Figure 2 – Model forStop-and-Wait ARQ |
Besides the knowledgegained in the lectures, I also find that the course is no longerthat much mysterious to me. In other words, I become to realize the mainpurpose of this technology as well as begin to consider practical problems fromthe specific points of view of the technology.
To learn the coursewell, in the past four weeks, I take the advice about insistingreading lecture notes as well as textbook for more than one hour per day fromprofessor liew. While reading the notes and the textbook, my goal is tounderstand how it is working and why people would design it like that, inaddition, I would try to think about my own ideas, which may look stupid ifcompared with the methods introduced in the lecture.
Topic:Comparison Between Two Functions – write() andsendto()
For socket programming, there are two kinds of functions that are for the same goal – senddata from one terminal to the other when communicating, they are write() andsendto(). The fundamental purpose of defining two different functions isbecause of the different usage for connection-oriented socket andconnectionless socket. Therefore, the architecture of these two kinds of socketis somehow different, which is shown as below:
![]() |
Figure 3 – ComparisonBetween Two Functions in Corresponding Architecture |
int write ( int sd, char *buf, intbuflen ) ;
int sendto ( int sd, char *buf,int buflen, int flags, stuct sockaddr *addrp, int addrlen) ;
--Communication Networks (Alberto Leon-Garcia)
From the above two lines,we can see that thetwo functions have three consistent components :
sd is the socket descriptor,
buf is a pointer to a buffercontaining the data to traansmitted ,
buflen is the length of the data inbytes . and also the sendto() function have three extra components :
flags can be used to controltransmission behavior such as handling out-of-band data
addrp is a pointer to the sockaddrstructure containing the address information of the remote hosts
addrlen is the lengeh of theaddress information
From my point of view, through the differences above we can easily see why sendto() is especially for connectionless, each time when sendto() is called, it will send datas with both source and destination addresses, which is no need for connection-oriented. And thus we can draw a conclusion that the essential difference between these two function is that one is for connectionless and the other is for connection-oriented.
In the further study, I would like to have the chance to have actual practice by using these socket functions, which will absolutely improve my acknowledge of the process of sending data by using different protocols.
没有评论:
发表评论