Socket programming and networking examples in Java.
At some specific computer, server usually runs. It consists of a socket which remains bound to some particular port number. Server’s function is to hold or wait and listen to socket if some client sends the connection request. On the client-side: Client is aware of the machine at which server runs has a hostname and a port number at which server listens. Client makes an attempt at the machine and port of the server to rendezvous with server so that to make the connection request.
Socket is basically the software endpoint which creates a bi-directional communication b/w client programs & a server program. A server program is associated by the socket with specific hardware port present at machine at which it runs and client program present in network along with socket which is being associated to similar port might do communication with server program.
Resource is provided by a server program to the client program network. Requests are sent by the client
Sockets provided communication channeled and support inter process communication in Java. For example to communicate between two JVMs, sockets are used. Socket is an end point for communication. There are two types of sockets. • Connection less sockets
• Connection oriented sockets
UDP protocol is used in the connection less sockets communication. Also they are referred as datagram communication protocol.
Each socket is indentified with following
Sometimes an application needs to communicate to a web server to send/receive data through HTTP. For example, connecting to a financial service to get stock price, posting user data to server to save in database, or checking for a new version of an application if available.
This article will guide you to write a generic utility method that can connect to a specified URL with either HTTP’s GET/POST method, and attaching parameters to the request. The method will return server’s response