Network programming in Linux is done through the socket interface, which is a file descriptor. Socket also has a function call similar to opening a file. This function returns an integer socket descriptor. Subsequent connection establishment and data transfer operations are implemented through sockets. There are 3 types of common sockets: (1) Streaming socket (SOCK_STREAM) streaming sockets provide a reliable, connection-oriented communication flow; it uses the TCP protocol to ensure the correctness and sequence of data transmission. (2) Datagram socket (SOCK_DGRAM) The datagram socket defines a connectionless service. Data is transmitted through mutually independent messages, which are unordered and are not guaranteed to be reliable and error-free. It uses the datagram protocol UDP. (3) Original socket, the original socket allows direct access to the underlying protocols such as IP or ICMP. It is powerful but inconvenient to use, mainly for the development of some protocols. 1.sockaddr/_in: is used to save socket information. After socketadd or sockaddr_in is created, the socket can be properly manipulated. Struct sockaddr { Unsigned short sa_family; /*address family*/ Char sa_data[14]; /*14 bytes of protocol address containing the IP address and port number of the socket. */ }; Struct sockaddr_in { Short int sin_family; /*address family*/ Unsigned short int sin_port; /*port number*/ Struct in_addr sin_addr; /*IP address*/ Unsigned char sin_zero[8]; /* padding 0 to keep the same size as struct sockaddr*/ }; Commonly used sa_family has the following types: AF_INET: IPv4 protocol AF_INET6: IPv6 protocol AF_LOCAL: UNIX Domain Protocol AF_LINK: Link Address Protocol AF_KEY: key socket (socket) 2. Data storage priority Computer data storage has two byte priority orders: high byte first (big endian mode) and low byte first (small segment mode). On the Internet, the high-order byte is prioritized in the network, and the PC usually uses the little-end mode, so sometimes it is necessary to convert the two-byte storage priority. Four functions are used: htons(), ntohs(), htonl(), and ntohl(). h stands for host, n stands for network, s stands for short, and l stands for long. Usually the 16-bit IP port number uses s, and the IP address uses l. Function format description Uint16_t htons(unit16_t host16bit) The parameter is the 16-bit data of the host endian Uint32_t htonl(unit32_t host32bit) The parameter is the 32-bit data of the host endian Uint16_t ntohs(unit16_t net16bit) The parameter is the 16-bit data of the network byte order. Uint32_t ntohs(unit32_t net32bit) The parameter is the 32-bit data of the network endian Address format conversion The IP address is usually represented by a digital dot (192.168.0.1), and the IP address used in struct in_addr is represented by a 32-bit integer. The following three functions can be used for conversion: The functions used in Pv4 are inet_aton, inet_addr, and inet_ntoa. Pv4 and IPv6 compatible functions are inet_pton and inet_ntop, where p is decimal and n is binary. Int inet_pton(int family, const char *strptr, void *addrptr) Int inet_ntop(int family, void *addrptr, char *strptr, size_t len) Family is passed to AF_INET or AF_INET6, addrptr is the converted address, strptr is the value to be converted, len is the size of the converted value, successfully returns 0, and the error returns -1. Int inet_aton(const char *cp,struct in_addr *inp); Char *inet_ntoa(struct in_addr in); In_addr_t inet_addr(const char *cp); Among them, inet_aton converts the IP in abcd format to 32-bit IP and stores it in the inp pointer; inet_ntoa converts 32-bit IP to abcd; inet_addr converts a dotted decimal IP into a long integer. Name address translation Usually, people don't want to remember lengthy IP addresses during use, so using hostnames is a good choice. Gethostbyname() converts the hostname to an IP address, and gethostbyaddr() is an inverse operation that translates the IP address to a hostname. They all involve a hostent structure, as follows: Struct hostent { Char *h_name; /* official host name */ Char **h_aliases; /*host alias*/ Int h_addrtype; /*address type*/ Int h_length; /* address byte length */ Char **h_addr_list; /* pointed to an IPv4 or IPv6 address pointer array */ }; We can get information about the hostent structure after calling gethostbyname() or gethostbyaddr(). 3. The basic functions of socket programming include socket(), bind(), listen(), accept(), sent(), sendto(), recv(), and recvfrom(), as described below. Based on TCP-Server: Create socket()—>bind() to bind IP address, port information to socket—>listen() set to allow maximum number of connections—>accept() wait for connection request from client—>send() , recv () or read (), write () send and receive data -> close the connection. Based on TCP-client: Create socket() -> set the IP address and port of the server to be connected, etc. -> connect() to connect to the server -> send(), recv() or read(), write() to send and receive data - >Close the network connection. Circular Server: The server can only respond to a client's request at the same time. Socket(...); Bind(...); Listen(...); While(1) { Accept(...); Process(...); Close(...); }
Product Features
1, built-in over-current overheating, temperature control circuit technology.
2, the module design, easy installation, online replacement.
3, low leakage current, fast response time, low residual voltage.
4, alarm indication device, green (normal) v red (fault).
Maximum Discharge
Current Imax(8/μ20μs)kA
Nominal Discharge
Current In(8/μ20μs)kA
Operating
Environment-C
Surge Protector SPD,Surge Protection Device SPD,SPD Wenzhou Korlen Electric Appliances Co., Ltd. , https://www.zjthermalrelay.com
Product Description
SPD Surge Protective Device,Lightning Surge Protector
Surge Protection Device (SPD)
It is a device used to limiting instant surge voltage and discharge surge current, it at least including a non-linear component.
Surge protective Device Model Selection
With the impact of international information flow, the rapid development of microelectronic science and technology, communication, computer and automatic control technology, make the building start to go for high quality, high functional area, formed a new building style-intelligent building. As inside the intelligent building there are lot of information system, <<Building lightning protection design norm>> GB50057-94(2002 vision)(hereafter brief as <<lightning protection norm>>) put forward the relative requirement to install the surge protective device, to ensure the information system safely and stable running.
SPD essentially is a equipotential connection material, its model selection is according to the different lightning protection area, different lightning electromagnetic pulse critical and different equipotential connection position, decide which kind of SPD used in the area, to achieve the equipotential connection with the common earth electrode. Our statement will based on SPD's maximum discharge current Imax, continuous operating voltage Uc, protection voltage Up, alarm mode etc.
As per << Lightning Protection Norm>> item 6.4.4 stipulation "SPD must can withstand the expected lightning current flow and should confirm to the additional two requirements: the maximum clamp voltage during surge across, capable to extinguish the power frequency follow-on current after lightning current across." That is the value of SPD's max. clamp voltage add its induction voltage of two ends should be same with the system's basic insulation level and the equipment allowed max. surge voltage.
SPD for Power Supply System Series Selection Guide
The installation of SPD at each lightning protection zone, according to the standard of low voltage electrical appearance, make classification of electrical equipment in accordance with the over voltage category, its insulation withstand impulse voltage level can determine the selection of SPD. According to the standard of low voltage electrical appearance, make classification of electrical equipment in accordance with the over voltage category as signal level, loading level, distribution and control level, power supply level. Its insulation withstand impulse voltage level are:1500V,2500V,4000V,6000V. As per to the protected equipment installation position different and the different lightning current of different lightning protection zone, to determine the installation position of SPD for power supply and the break-over capacity.
The installation distance between each level SPD should not more than 10m, the distance between SPD and protected equipment should as short as possible, not more than 10m. If due to limitation of installation position, can't guarantee the installation distance, then need to install decoupling component between each level SPD, make the after class SPD can be protected by the prior class SPD. In the low voltage power supply system, connecting an inductor can achieve the decoupling purpose.
SPD for power supply system specification selection principle
Max. continuous operating voltage: bigger than protected equipment, the system's max. continuous operating voltage.
TT System: Uc≥1.55Uo (Uo is low voltage system to null line voltage)
TN System: Uc≥1.15Uo
IT System: Uc≥1.15Uo(Uo is low voltage system to line voltage)
Voltage Protection Level: less than the insulation withstand impulse voltage of protected equipment
Rated discharge current: determined as per to the lightning situation of the position installed and lightning protection zone.
SP1 Series
Normal Working Conditions
-Altitude not exceed 2000m
-Ambient air temperature:
Normal range: -5ºC~+40ºC
Extend range: -40ºC~+80ºC
-Relative Humidity: 30% - 90% under indoor temperature condition
- At the place without obviously shaking and shock vibration
- Non-explosion danger medium, non-corrosion gas and dust ( including conductive dust)
Classification
-As per Nominal Discharge Current:
5,10,20,30,40,60KA(8/20µs)
- As per Maximum continuous operating voltage:
275V,320V,385V,420V,440V,460V
- As per to poles
1P,1P+N,2P,3P,3P+N,4P
- As per auxiliary functions:
a. With remote signal output ( remote alarm function)
b. Without remote signal output
Selection Principle
- The continuous applied voltage on the two terminals of SPD should not more than the maximum continuous operating voltage Uc value;
- The voltage protection level Up of SPD should less than the maximum impulse withstand voltage of the protected equipment;
- As per to the different earthing system and protection mode to select the specification accordingly;
Model/Technical Parameters
WR-B60
WR-B80
WR-B100
WR-B120
WR-B150
Rated Operating Voltage Un (V ~)
220V 380V
220V 380V
220V 380V
220V 380V
220V 380V
Maximum Continuous Operating Voltage Uc (V ~) kV
385V 420V
385V 420V
385V 420V
385V 420V
385V 420V
Voltage Protection Level Up (V ~) kV
≤1.8≤2.2
≤2.4≤2.5
≤2.5≤3.2
≤3.4≤3.7
≤4.0≤4.5
60
80
100
120
150
30
40
60
80
100
Response Time
<25
<100
L/N(mm²)The Cross Section Of L/N Line
16,25
16,25
16,25
16,25
25,35
PE (mm²)The Cross Section Of PE Line
16,25
25,35
25,35
25,35
35
Fuse or Switch (A)
63A
63A
63A,100A
63A,100A
63A,125A
The Line Section of Communication and Alarm (mm²)
≥ 1.5
(-40ºC~-+85ºC)
Relative humidity 25 ºC
≤95%
installation
Standard Rail35mm
Material of Outer Covering
Fiber Glass Reinforced Plastic