Presentation On Socket Programming
LAN BASED
Mini Project
Contents
 Socket Programming
 Server-Client Communication
 .net Package
 The InetAddress Class & its methods
 getLocalHost()
 getByName(String hostName)
 getAllByName(String hostName)
 getAddress() & getHostName()
 Socket Class
 ServerSocketClass
Socket Programming
Networking - process of making two or more computers communicate.
The important concept associated with networking is the concept of
Sockets and Ports.
SOCKET - A socket is one end-point of a two-way communication link
between two programs running on the network.
Socket classes are used to represent the connection between a client
program and a server program.
Server-Client
Communication
 Normally, a server has a socket that is bound to a specific port
number.
 On the client-side: The client knows the hostname of the machine on
which the server is running and the port number on which the server
is listening.
 To make a connection request, the client tries to connect with the
server on the server's machine and port.
 If everything goes well, the server accepts the connection.
 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.
.net Package
 Provide support for networking.
 Contains classes and interfaces to encapsulate the
“Socket” Paradigm.
 The java.net package provides two classes—
 Socket - implement the client side of the connection
 ServerSocket- implement the server side of the connection
Socket Class
 The Socket class ,basically used to create client sockets, is
designed to connect to server socket and initiate protocol
exchanges.
 When Socket object is created, it implicitly establishes the
connection b/w client and server.
 Socket defines the constructors to create client sockets.
Constructors:-
Socket(String hostname, int port);
Socket(InetAdrress ipaddr, int port);
ServerSocket Class
The ServerSocket class, basically used to create server sockets, is
designed to be a listener, which waits for client to connect before
doing anything.
Constructors:-
ServerSocket ( int port );
ServerSocket ( int port, int queueLength);
Method:-
Socket accept();
accept() is a blocking call that waits for a client to initiate
communication and returns a normal Socket, that is used for
communication with the client.
Client server project
Client server project
Client server project

Client server project

  • 1.
    Presentation On SocketProgramming LAN BASED Mini Project
  • 2.
    Contents  Socket Programming Server-Client Communication  .net Package  The InetAddress Class & its methods  getLocalHost()  getByName(String hostName)  getAllByName(String hostName)  getAddress() & getHostName()  Socket Class  ServerSocketClass
  • 3.
    Socket Programming Networking -process of making two or more computers communicate. The important concept associated with networking is the concept of Sockets and Ports. SOCKET - A socket is one end-point of a two-way communication link between two programs running on the network. Socket classes are used to represent the connection between a client program and a server program.
  • 4.
    Server-Client Communication  Normally, aserver has a socket that is bound to a specific port number.  On the client-side: The client knows the hostname of the machine on which the server is running and the port number on which the server is listening.  To make a connection request, the client tries to connect with the server on the server's machine and port.  If everything goes well, the server accepts the connection.  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.
  • 5.
    .net Package  Providesupport for networking.  Contains classes and interfaces to encapsulate the “Socket” Paradigm.  The java.net package provides two classes—  Socket - implement the client side of the connection  ServerSocket- implement the server side of the connection
  • 6.
    Socket Class  TheSocket class ,basically used to create client sockets, is designed to connect to server socket and initiate protocol exchanges.  When Socket object is created, it implicitly establishes the connection b/w client and server.  Socket defines the constructors to create client sockets. Constructors:- Socket(String hostname, int port); Socket(InetAdrress ipaddr, int port);
  • 7.
    ServerSocket Class The ServerSocketclass, basically used to create server sockets, is designed to be a listener, which waits for client to connect before doing anything. Constructors:- ServerSocket ( int port ); ServerSocket ( int port, int queueLength); Method:- Socket accept(); accept() is a blocking call that waits for a client to initiate communication and returns a normal Socket, that is used for communication with the client.