Прејди на содржината

Computer network programming

Од Википедија — слободната енциклопедија

Mрежното програмирање, суштински идентично со приклучок програмирање или клиент-сервер програмирање, вклучува пишување компјутерски програми кои комуницираат со други програми низ компјутерската мрежа. Програмата или процесот кој ја иницира комуникацијата е наречен клиент процес, а програмата која чека на комуникацијата да биде започната е сервер процес. Клиент и сервер процесите заедно формираат распределувачки систем. Комуникацијата помеѓу клиент и сервер процесот може да е конекциски-ориентирана (како и утврден TCP virtual circuit или session), or connectionless (based on UDP datagrams).

A program that can act both as a client and a server is based on peer-to-peer communication.

Sockets are usually implemented by an API library such as Berkeley sockets, first introduced in 1983. Most implementations are based on Berkeley sockets, for example Winsock introduced 1991. Other socket API implementations exist, such as the STREAMS-based Transport Layer Interface (TLI).

These are examples of functions or methods typically provided by the API library:

  • socket() creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it.
  • bind() is typically used on the server side, and associates a socket with a socket address structure, i.e. a specified local port number and IP address.
  • listen() is used on the server side, and causes a bound TCP socket to enter listening state.
  • connect() is used on the client side, and assigns a free local port number to a socket. In case of a TCP socket, it causes an attempt to establish a new TCP connection.
  • accept() is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection.
  • send() and recv(), or write() and read(), or recvfrom() and sendto(), are used for sending and receiving data to/from a remote socket.
  • close() causes the system to release resources allocated to a socket. In case of TCP, the connection is terminated.

See also

Предлошка:Compu-prog-stub