0
2.4kviews
Short note on Socket Programming?
1 Answer
0
75views

A socket is one of the most fundamental technologies of computer network programming. Socket programming is a way of connecting two nodes on a network to communicate with each other. Socket programs are used to communicate between various processes usually running on different systems. It is mostly used to create a client-server environment.

The socket mechanism provides a means of inter-process communication (IPC) by establishing named contact points between which the communication take place.

Socket are generally employed in client server applications. The server creates a socket, attaches it to a network port addresses then waits for the client to contact it. The client creates a socket and then attempts to connect to the server socket. When the connection is established, transfer of data takes place.

Socket Libraries and APIs in programming: Many libraries that implement standard application programming interfaces (ie.APIs) exist on the internet. The first mainstream package which is the Berkeley Socket Library, is widely in use on UNIX systems. Another common API is the Windows Sockets (WinSock) library for Microsoft operating systems. Relative to other computer technologies, socket APIs are mature.

The socket APIs are relatively small and simple. Many of the functions are similar to those used in file input/output routines such as <tt>read()</tt>, <tt>write()</tt>, and <tt>close()</tt>. The actual function calls to use depend on the programming language and socket library chosen.

There are different types of Socket Interface:

  • Stream Socket: A stream socket is type of interprocess communications socket or network socket which provides a connection-oriented, sequenced, and unique flow of data without record boundaries with well defined mechanisms for creating and destroying connections and for detecting errors. These sockets use TCP (Transmission Control Protocol) for data transmission. If delivery is impossible, the sender receives an error indicator.

  • Datagram Socket: Datagram Socket have connectionless point for sending and receiving package, because you don't need to have an open connection as in Stream Sockets. In datagram socket you just build a packet with the destination information and send it out, just like mailbox. Datagram Socket uses UDP (User Datagram Protocol).

  • Raw Sockets: Raw sockets are not for the general users, they have been provided mainly for those interested in developing new communication protocols, or for gaining access to some of the more cryptic facilities of an existing protocol. Raw sockets are used for custom low-level protocol development. Raw Socket provides users access to the underlying communication protocols, which support socket abstractions. These sockets are basically datagram oriented, though their exact characteristics are dependent on the interface provided by the protocol.

  • Sequenced Packet Sockets (SPS): Sequenced Packet Sockets are similar to Stream Sockets, with the exception that record boundaries are preserved. SPP interface is only provided as part of the network system socket abstraction and is very important in most serious network system applications. SPS allows the user to receive the header on incoming packets. It also allows the user to modify the SP Protocols header on a packet or a group of packets, either by writing a prototype header along whatever data is to be sent or by specifying a default header to be used with all outgoing data.

Please log in to add an answer.