Sockaddr structSockaddr's defect: sa_data mixed the target address and port information
Struct sockaddr {Unsigned short sa_family;Char sa_data [14];};
Sa_family is the communication type, and the most common value is "af_inet"Sa_data14 bytes, including the destination address and port information in the socket
Sockaddr_in structThe sockaddr_in struct solves the sockaddr defect and stores the port and ADDR separately in two variables.
Struct sockaddr_in {Short int
short B's byte order is:01 02This is the network byte sequence. The order we see is the same as the order in the memory!Assume that the two byte streams of network data obtained through packet capture are: 01 02
The byte order is different. The order in the memory is 02 01.If this represents two bytes, you do not need to consider the byte sequence. If this represents a short variable, you need to consider the byte sequence. According to the "WYSIWYG" rule in the byte sequence of the network, th
"10.003.2.0x12 ".
We mentioned the client code in the previous socket programming and connected the local port:
/* File Name: client. c */# include Iii. Host Byte Order format (HBO, Host Byte Order)
The format of the host's byte sequence is as the name suggests. The IP address format is related to a specific host or router. For different hosts, there are different formats for storing IP addresses. For example, for Motorola 68k series hosts,
, it is a little troublesome to indicate this variable:Define the variable short X,The byte stream address is PT, And the READ memory isX = * (short *) pt );The memory order of X is certainly 01 02.According to the rules that are not "WYSIWYG", the memory order is obviously the same as that seen, so we need to change the positions of these two bytes.The change method can be defined by yourself, but it is more convenient to use existing APIs.
Network byte sequence and host byte sequenceNbo and
Write network in C/C ++ProgramThe Network order of the bytes and the host order are often encountered. You may use the htons (), ntohl (), ntohs (), and htons () functions.
The conversion function between the network byte sequence and the local byte sequence:
Htonl () -- "host to network long"
ntohl () -- "network to host long"
htons () -- "host to network short"
ntohs () -- "network to host short"
These functions are required because the computer data indica
rid of its heavy shackles. Since then, Netflix has been devoting resources and money to making a series of homemade dramas. In return, the number of paid users surpassed HBO and the share price rose to $450. In 2015, Netflix earned $7 billion, paying users 66 million, of which 42 million in the US, with profits of about $80 million to $100 million.
We want to develop Netflix into HBO before
First he introduces Apple stores in China at the selected address. And the designer of the Apple retail store in Hangzhou is the same person as the designer at Apple's headquarters. More than 1.2 million users visited the Apple store in the previous quarter. Apple has already opened 21 Apple Store stores in China, and the plan will continue to grow.
HBO independent streaming media services, with Apple as of the lau
Write network in C/C ++ProgramThe Network order of the bytes and the host order are often encountered. Htons (), ntohl (),Ntohs () and htons () functions.
The conversion function between the network byte sequence and the local byte sequence:
Htonl () -- "host to network long"Ntohl () -- "networkHost long"Htons () -- "host to network short"Ntohs () -- "NetworkTo host short"
These functions are required because the computer data indicates that there are two byte sequences: nbo and
Write network in C/C ++ProgramThe Network order of the bytes and the host order are often encountered. You may use the htons (), ntohl (), ntohs (), and htons () functions.
The conversion function between the network byte sequence and the local byte sequence:
Htonl () -- "host to network long"
Ntohl () -- "network to host long"
Htons () -- "host to network short"
Ntohs () -- "network to host short"
These functions are required because the computer data indicates
Solaris, Aix, MacOS, freebsd5, and HPUX are all large ends,(Network byte order) uses the big end.Therefore, it is necessary to convert HBO and nbo.# Include Uint16_t htons (host)Uint32_t htonl (host)// HBO-nboUint16_t ntohs (network)Uint32_t ntohl (network)// Nbo-> HBO
3.5-byte manipulation FunctionFor data such as IP addresses, there is 0 in the middle, but t
encounter the problem of byte network order and host order. This is the 4 functions that may be used to htons (), Ntohl (), Ntohs (), htons ().The conversion function between the network byte order and the local byte order:HTONL ()--"Host to Network Long"Ntohl ()--"network to Host Long"Htons ()--"Host to network short"Ntohs ()--"network to Host short"These functions are required because the computer data represents two byte orders: network byte order Nbo (network byte) and host byte order
variable is: 0102Assuming the local host is an Intel type, it's a bit cumbersome to represent this variable:Define variable short X,The byte stream address is: PT, in order to read the memory isx=* ((short*) PT);So the memory order of X is 01 02, of course.According to the "WYSIWYG" rule, this memory sequence is clearly not the same as the one you see, so swap the two byte positions.The replacement method can be defined by itself, but it is more convenient to use an existing API.Network byte or
homes and enterprises at extremely fast speeds. Several months ago, several fiber cables crossed the road from outside my house-but they were not directly connected to my house. Optical fiber is committed to bringing unprecedented network speeds to workplaces and homes, thus revolutionizing telecommunication and connection technologies. For example, Verizon now uses their FiOS product to provide a speed of 15 megabytes/second. If this speed can be us
/Captiva
Endeca
Exalead
Exsys
Extensis
Fast
FIOS
Global 360
Google
Groxis
Handysoft
Hewlett-Packard
IBM/Lotus/filenet
Inquira
Intelliisearch
Interwoven
Isys search software
Jive Software
Justsystems
Kana
Kazeon Systems
Knova, A consona CRM Company
Kofax
Kroll ontrack/engenium search
Liberty IMS
Lockheed Martin
Mark Logic
Mediasurface
Metastorm
Microsoft
Mondosoft
Netdocuments
New Idea Engineering
Nextpage
Noetix
Nort
SopCastPlayer is a Linux Player Based on p2p stream technology. sopCast can play many TV channels online for free, such as football matches and HBO. there are also many local and international channels that you can find on Google and play with sopcastplayer. ubuntu 10.10 installation 1. use Ubuntu-Tweak to install VLC2.32 bits: Download libstdc ++ 5, sp-auth, and
SopCast Player is a Linux Player Based on p2p stream technology. sopCast can play many T
Ntohs =net to host short int 16 bitHtons=host to net short int 16 bitNtohl =net to host long int 32 bitHtonl=host to net long int 32 bitNET byte order Nbo (network byte orders)Store in order from high to low, use the same network byte order on the network to avoid compatibility problems;Host byte order HBO (host byte order)Different machine HBO is not the same, with the CPU design, the data order is determi
byte sequence (hbo,host byte order): Different machine HBO is not the same, related to CPU design, the order of data is determined by the CPU, and operating system independent.such as the Intel x86 structure, the short type number 0x1234 is expressed as a decimal, the int type number 0x12345678 is expressed as 78 56 34 12such as the IBM Power PC structure, the short type number 0x1234 is expressed as a 0x1
{in_addr_t s_addr;};(5)structSockaddr_in{__sockaddr_common (sin_); in_port_t Sin_port;/*Port number.*/structIN_ADDR sin_addr;/*Internet address.*//*Pad to size of ' struct sockaddr '.*/unsignedCharsin_zero[sizeof(structSOCKADDR)-__sockaddr_common_size-sizeof(in_port_t)-sizeof(structin_addr)];};(6) struct SOCKADDR This structure is the Linux network programming interface used to represent the IP address of the standard structure, bind, connect and other functions need this structure, the structur
network communication often involves byte-order conversion, then understand the host sequence and network order what similarities and differences.① host byte order HBO (host byte order)Use small-endian (Little-endian), low-to-high sequential storage.The low byte is emitted at the lower address end of the memory, and the high address is discharged at the high address.② Network byte order Nbo (NET byte order)Use the Big Head Order (Big-endian), from hig
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/yu444/archive/2010/05/13/5587781.aspx
What is the network byte order and host byte order?
When doing network programming, you need to transform to unify the "format"
Briefly:
Network byte sequence Nbo (network byte order):You can avoid compatibility problems by storing them in order from highest to lowest, using a uniform network byte order on the network.Host byte sequence (
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.