JAVA NETWORKING TCP/IP CLIENT SOCKETS CONTENTS
TCP/IP
CLIENT SOCKETS
Transmission control protocol(TCP) is a
connection-oriented, reliable protocol
which supports the transfer of data in continuous streams.
The addressing scheme used in TCP is makes use of
ports.
This type of communication is called as socket
programming.
Port number Service
21 FTP
23 Telnet
25 SMTP
80 HTTP
110 POP3
A socket is bound to a port number so that the TCP/UDP
from transport layer can identify the corresponding application at destination.
![]() |
TCP/IP CLIENT SOCKETS |
Server is a device which has resources and from which
the services can be obtained.
Client is
a device which wants to get service from particular server.
Client
|
Server
|
|
1
|
Creates TCP socket
|
Creates TCP socket
|
2
|
Client initiates the communication.
Communicate
|
Creates another socket for listening client.
Accept message from client and repeatedly communicate.
|
3
|
Close the connection
|
Close the connection
|
![]() |
TCP/IP CLIENT SOCKETS |
These steps can be illustrated by following figure:
There are
two constructors used to create client socket.
Constructor
|
Meaning
|
Socket(String hostname , int port)
|
Creates a socket connecting the local
host to the named host and port.
|
Socket(InetAddress ipAddress , int port)
|
Creates a socket using a pre-existing
InetAddress object and a port.
|
The methods used for examining the socket are.
InetAddress getInetAddress()
|
Returns the InetAddress associated
with the Socket object.
|
Int getPort()
|
Returns the remote port to which this
Socket object is connected.
|
Int get.ocalPort()
|
Returns the local port to which this
|
Post a Comment