Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to implement TCP in vxworks

Shulou Source: shulou.com Published: 2022-06-01 09:47:08 09月16日 Update

This article mainly shows you "how to achieve TCP in vxworks", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to achieve TCP in vxworks" this article.

TCP, whose full name should be Transmission Control Protocol, is a connection-oriented transport layer protocol that provides reliable byte streaming. When communicating, similar to UDP, it also uses Cmax S mode, that is, start a Server, which is responsible for blocking reception, and send data after other Client connections. However, the whole process is a little more complicated than UDP, and the transmission efficiency is lower.

Let's take a look at the client side first, it's a little simpler.

Client calls socket () to open a Socket

Client calls connect () to connect to the specified Server

Client calls send () to send data

Finally, call close () to close Socket

Server is a little more complicated.

Server calls socket () to open a Socket

Server calls bind () to specify information such as Port

Server calls listen () to start listening to Client

Server calls accept () to wait for the access of Client

Server calls recv () to block reception

Finally, call close () to close Socket

In order to support the access of multiple Client, Server can call accept () multiple times; in order to process the multiple Client in parallel, you can put the recv () of each Client into a separate task

In addition, Service can also call send (), Client can also call recv () and Socket is a virtual IO. After data processing, both parties need to call close () to close their Socket, and they can also use read () instead of recv () and write () instead of send (). Several other functions and data structures are as follows. The type of function input parameter is generally sockaddr structure, while the declared variables generally use sockaddr_in structure to specify Port and IP. In fact, they are the same thing.

Write the simplest example

Client is as follows

These are all the contents of the article "how to achieve TCP in vxworks". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Data content article structure complexity function multiple transmission processing learning help access blocking task information full name both parties variables things efficiency Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Apple Linux Shulou Tech Info