The communication model of socket communication in linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. Guidance:
1. Socket Introduction
Socket is a TCP/IP network API that can be used to
Obtain the local IP Address
The local machine may have multiple IP addresses. The following program can obtain the local IP Address:
Struct hostent * h;
Char host [100];
Int I;
Gethostname (host, 100 );
If (H = gethostbyname (host) = NULL ){
Network Socket data transmission is a special type of I/O, and Socket is also a file descriptor. Socket also has a function called Socket () similar to opening a file. This function returns an integer Socket descriptor, and subsequent connection
Simply call a function to gethostbyname (),gethostbyname () returns a hostent structure pointer to the host name and address information that corresponds to the given host name. The declaration of the structure is consistent with the GETHOSTADDR ().
In daily life, people often know the host domain name without knowing the host IP address, and the socket API is based on IP address, so need to use DNS domain name resolution server to parse.So the first simple introduction of the principle of DNS,
What is a socketThe socket interface is a TCP/IP network Api,socket interface that defines many functions or routines that programmers can use to develop applications on a TCP/IP network. To learn about TCP/IP network programming on the Internet,
Php obtains the summary of root domain names, and php obtains the summary of domain names.
The examples in this article summarize how php obtains the root domain name and share it with you for your reference. The specific implementation method is as
Summary of PHP methods for obtaining domain names, and summary of php methods for obtaining domain names
This example summarizes the PHP method for obtaining domain names. Share it with you for your reference. The specific implementation method is
Summary of PHP methods for obtaining domain names, and summary of php methods for obtaining domain names. Summary of PHP methods for obtaining domain names; summary of php methods for obtaining domain names this article provides an example of PHP
Socket is the network connection endpoint. I. Introduction to Network Knowledge
Socket is the network connection endpoint. For example, when your Web browser requests the homepage of www.bitsCN.com, your Web browser creates a socket and commands it
Domain name resolution application knowledge
Generally, the gethostbyname system function is used to resolve the domain name to obtain the IP address. However, in Linux, gethostbyname is insecure due to multiple threads. This function uses
1. The hostent data structure is as follows:Struct hostent {Const char * h_name; // official name of hostChar ** h_aliases; // Alias ListShort h_addrtype; // host address typeShort h_length; // length of addressChar ** h_addr_list; // list of
The data structure is as follows:Struct hostent {Const char * h_name; // official name of hostChar ** h_aliases; // Alias ListShort h_addrtype; // host address typeShort h_length; // length of addressChar ** h_addr_list; // list of addresses from
Connection-oriented socket instance
CodeThe server in the instance sends the string "Hello, you are connected!" to the client through a socket connection !". If you run the software on the server and the client runs the software on the client,
PHP implementation of the method to get the domain name summary, PHP get the domain name summary
This paper summarizes the method of getting the domain name by PHP implementation. Share to everyone for your reference. The implementation method is
C IP Address knowledge points: structsockaddr {unsigned Shortsa_family; Charsa_data[ -]; }; sockaddr_in Detailed sa_family is the address family, is generally "af_xxx" form. Most commonly used are af_inet, which represents the address group Sa_data
The general way to learn C language is to first learn C and then C ++. It is best to have the basis of assembly language and microcomputer principles, followed by Visual C ++. This method takes a lot of time and endurance for learners. In school
What is socket
A socket interface is an API of a TCP/IP network. A socket interface defines many functions or routines. programmers can use it to develop applications on a TCP/IP network. To learn TCP/IP network programming on the internet, you
PHP Get root domain method Summary, PHP get domain name summary
This article summarizes the PHP get root domain name method, share to everyone for your reference. The implementation method is as follows:
If you simply get the current access to your
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.