Socket programming

  • 1,101 views
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,101
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
39
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • 07/06/11
  • 07/06/11

Transcript

  • 1. SOCKET PROGRAMMING Name:: Gohel Jigar k. ID :: M09018
  • 2. WHAT IS SOCKET
    • To establish a connection between one host and another in a network.
      • Ends points of two-way communications, i.e., logical connections between hosts
      • Can be used to send and receive data
      • Server vs. client sockets
  • 3. SOCKET logical connection sockets (end points) A socket is an endpoint for communication between two machines.
  • 4. TOW TYPE OF SOCKET
    • Server sockets
      • Wait for requests to come in over the network
      • Implemented by java.net.ServerSocket class
    • Client sockets
      • Used to send and receive data
      • Can be thought of as a pair of input and output streams
      • Implemented by java.net.Socket class
  • 5. SERVER VR. CLIENT SOCKET
    • Server socket: waiting for connection requests
    • Client socket: transmission of data
    server socket connection request client socket
  • 6. SERVER SOCKET
    • Constructors
    • The constructors used to server socket are given below. All of them throw IO Exception
    • Server Socket(int port)
    • Server Socket(int port , int q)
  • 7. SERVER SOCKET
    • Methods
    • Some method defined in the Server Socket are:
    Methods Description accept() Waits for a connection request and returns a Socket getInetAddress() Returns the local address of this server Socket Int getLocalPort() Returns the port number on which this socket is listening close() Stops waiting for requests from clients
  • 8. CLIENT SOCKET
    • Constructors
    • The constructors used to server socket are given below. All of them throw IO Exception
    • Socket(String host, int port)
    • Socket(inetAddress address, int port , inetAddress localadrs, int localport )
  • 9. CLIENT SOCKET
    • Methods
    • Some method defined in the Server Socket are:
    Methods Description getInetAddress() Returns IP address to which socket are connected. getLocalAddress() Returns local address to which socket are connected. getInputStream() Returns an InputStream for receiving data. getOutputStream() Returns an OutputStream to send data. close() Closes the socket connection.
  • 10. ADVANTAGES SOCKET PROGRAMMING
    • Efficient socket based programming can be easily implemented for
    • general communications.
  • 11. THANKS