Computer network programming
Encyclopedia
In computing
, network programming, essentially identical to socket
programming or client–server programming, involves writing computer programs that communicate with other programs across a computer network
. The program or process initiating the communication is called a client
process, and the program waiting for the communication to be initiated is the server
process. The client and server processes together form a distributed system. The communication between the client and server process may either be connection-oriented
(such as an established TCP
virtual circuit
or 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 in 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:
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
, network programming, essentially identical to socket
Internet socket
In computer networking, an Internet socket or network socket is an endpoint of a bidirectional inter-process communication flow across an Internet Protocol-based computer network, such as the Internet....
programming or client–server programming, involves writing computer programs that communicate with other programs across a computer network
Computer network
A computer network, often simply referred to as a network, is a collection of hardware components and computers interconnected by communication channels that allow sharing of resources and information....
. The program or process initiating the communication is called a client
Client (computing)
A client is an application or system that accesses a service made available by a server. The server is often on another computer system, in which case the client accesses the service by way of a network....
process, and the program waiting for the communication to be initiated is the server
Server (computing)
In the context of client-server architecture, a server is a computer program running to serve the requests of other programs, the "clients". Thus, the "server" performs some computational task on behalf of "clients"...
process. The client and server processes together form a distributed system. The communication between the client and server process may either be connection-oriented
Connection-oriented
Connection-oriented communication is a data communication mode in telecommunications whereby the devices at the end points use a protocol to establish an end-to-end logical or physical connection before any data may be sent. In case of digital transmission, in-order delivery of a bit stream or...
(such as an established TCP
Transmission Control Protocol
The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is one of the two original components of the suite, complementing the Internet Protocol , and therefore the entire suite is commonly referred to as TCP/IP...
virtual circuit
Virtual circuit
In telecommunications and computer networks, a virtual circuit , synonymous with virtual connection and virtual channel, is a connection oriented communication service that is delivered by means of packet mode communication...
or session
Session (computer science)
In computer science, in particular networking, a session is a semi-permanent interactive information interchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user . A session is set up or established at a certain point...
), or connectionless (based on UDP
User Datagram Protocol
The User Datagram Protocol is one of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer applications can send messages, in this case referred to as datagrams, to other hosts on an Internet Protocol network without requiring...
datagrams).
A program that can act both as a client and a server is based on peer-to-peer
Peer-to-peer
Peer-to-peer computing or networking is a distributed application architecture that partitions tasks or workloads among peers. Peers are equally privileged, equipotent participants in the application...
communication.
Sockets are usually implemented by an API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...
library such as Berkeley sockets
Berkeley sockets
The Berkeley sockets application programming interface comprises a library for developing applications in the C programming language that perform inter-process communication, most commonly for communications across a computer network....
, first introduced in 1983. Most implementations are based on Berkeley sockets
Berkeley sockets
The Berkeley sockets application programming interface comprises a library for developing applications in the C programming language that perform inter-process communication, most commonly for communications across a computer network....
, for example Winsock
Winsock
In computing, the Windows Sockets API , which was later shortened to Winsock, is a technical specification that defines how Windows network software should access network services, especially TCP/IP. It defines a standard interface between a Windows TCP/IP client application and the underlying...
, introduced in 1991. Other socket API implementations exist, such as the STREAMS-based Transport Layer Interface
Transport Layer Interface
In computer networking, the Transport Layer Interface was the networking API provided by AT&T UNIX System V Release 3 in 1987 and continued into Release 4 . TLI was the System V counterpart to the BSD sockets programming interface, which was also provided in UNIX System V Release 4...
(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
andrecv
, orwrite
andread
, orrecvfrom
andsendto
, 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.
External links
- Beej's guide to network programming
- http://www.kohala.com/start/preface.unpv12e.html
- http://java.sun.com/docs/books/tutorial/networking/overview/networking.html
- Network Programing For Python PyQt4