Socket Programming (another Internet Programming)

on Wednesday 10 July 2013

Overview


Internet programming is the process of implementing the algorithm by using a computer programming language that can communicate in a network through a protocol, a database interface, programming Graphics User Interface (GUI) or the structure of the information. As we know that a computer can communicate with other computers using a protocol (a protocol that has been known to be called IP). It can provide inspiration for further exploration of programming, such as programming a web-based information system that involves the use of database systems, programming applications remotely control and so forth.

One of the important programming studied within the scope of this is client server socket programming. By studying the socket programming techniques, it can be seen how the way a computer can send messages with text, video images, music, or other over the internet.

What is a Socket?


Socket is one endpoint of a two-way communication between two programs running on the network with TCP / IP or UDP. Socket connected to a port number so that the TCP layer can identified applications where data transmission is intended. Socket is an application created, controlled operating system interface in which applications are able to send and receive messages from or to another application.

Definition of the socket as follows (Shuttleworth, 2003, p.5):
  • Permit a unique process to communicate one with others
  • Inform the process where to write or read
  • Communication on the same machine, network and The Internet
  • Communication two direction make match for the client server model
  • Be formed 1980 by Berkeley Unix Distribution
In general, a server is a special computer and has a socket that is connected to a specific port number. Servers just waiting to accept socket connection requests (request) from a client (passive open). Clients know the name of the machine where the server is running and port number where the server is connected. To make a connection request, the client tries to connect to the server on the server machine and port (active open).

If all goes well, the server accepts connections (virtual circuits). When receiving, the server opens a new socket which is connected to a different port. To be continued acceptance of the initial socket for connection requests while serving the needs of the connected client, needed a new socket (with a different port number).

On the client side, if the connection is accepted, a socket is successfully created and the client can use the socket to communicate with the server. Client and server can now communicate to write or read from the socket.

There are 2 kinds of protocols can be used on the socket, namely:
  1. TCP connection-oriented and reliable
    • Connection-oriented, to do communication be required connection especially ago
    • Reliable, guarantee arriving data packets to computer destination and do checking. If there is data packets are lost or damaged the TCP socket will ask corrupted data packets or disappear mentioned to all received data packet in good condition.
  2. UDP is connectionless and unreliable.
    • Some commonly used port number 21 (FTP), 23 (telnet), 25 (SMTP), 69 (TFTP), 80 (HTTP), 161 (SNMP).

Type Socket


When a socket is formed, the program must specify the domain address and the socket type. Two processes can communicate with each other only if the type and the same domain. There are two commonly used address domains, namely:
  • Unix domain socket that is not can reach from the Internet directly, but with with advent demand on the server.
  • Internet domain is two processes running on two host fruit in communication the Internet. socket address of The Internet domain consists the Internet address of host machine. Apart it, each socket requires port number on the host. No. ports such as 16-bit unsigned integers. figure is low provided in Unix to service standards. As example, the port number for the FTP server is 21. It is important that service standard will be on the same port on all computer so that the client will know address. Well-known port numbers is no available port 65536.

For there are two kinds of socket types, Stream and Datagram socket socket (www.redbrick.dcu.ie/).
  • Stream socket is communication continuous stream of character (using TCP protocol)
  • Datagram socket is reading whole message with immediately (using UDP protocol)

Windows Sockets (WinSock)


Windows operating system has an Application Programming lnterface (API) to communicate over TCP / IP is known as WinSock API. Programming API itself is very difficult because the programming API has been dealing with low level. Low levels are not allowed to be accessed directly. However, Windows has provided API, which is a set of functions to access the lower level. To assist programmers in terms of making software that can communicate with other computers then provide an ActiveX control component named Winsock Control.

Winsock specifically defined by how a Windows network software should access network services, especially TCP / IP (definition-info.com). Winsock provides a single API where developers of software applications and networks need to adapt. For some versions of Windows, winsock is defined as a binary interface that ensures a match on the Winsock API applications that can run on the network from different software developers. Winsock based on BSD (Berkeley) sockets, but provide additional functionality that allows programming API works on standard window.
With Winsock control the programmers do not need to know the details of TCP / IP and API function calls to set up a network for application programmers to use only methods, properties or events held by Winsock. Process of client-server communication using sockets can be seen in the image below:



0 comments:

Post a Comment