• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Sockets in nach0s
 

Sockets in nach0s

on

  • 975 views

 

Statistics

Views

Total Views
975
Views on SlideShare
919
Embed Views
56

Actions

Likes
0
Downloads
9
Comments
0

3 Embeds 56

http://os-class.blogspot.com 45
http://os-class.blogspot.mx 10
http://www.blogger.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Sockets in nach0s Sockets in nach0s Presentation Transcript

    • SOCKETS IN NACH0S
        Socket types:
      • STREAM- Uses TCP which is realiable, stream oriented protocol.
      • RAW- Provides RAW data transfer directly over IP protocol.
      • DATAGRAM- Message oriented protocol.
    • SOCKETS IN NACH0S
        Socket use:
      • Unicast
      • Multicast
      • Broadcast
      • Loopback
    • SOCKETS IN NACH0S
        Programming Client-Servidor in JAVA
      • All the class located in the java.net package.
      • Stream classes are in the java.io package.
    • SOCKETS IN NACHOS
        How open a socket?
      • For programming a client, create an object of Socket class.
      Socket Client; try { Client = new Socket("Machine name", PortNumber); } catch (IOException e) { System.out.println(e); }
    • SOCKETS IN NACH0S
      • For programinng a server, in this part how you open a socket.
      ServerSocket Service; try { Service = new ServerSocket (PortNumber); } catch (IOException e) { System.out.println(e); }
      • When implementing a server you also need create a socket object.
      Socket clientSocket = null; try { clientSocket = Service.accept(); } catch (IOException e) { System.out.println(e); } SOCKETS IN NACH0S
    • SOCKETS IN NACH0S
        How to create an imput Stream ?
      • You can use the DataImputStream class .
      DataInputStream input; try { input = new DataInputStream (Client.getInputStream()); } catch (IOException e) { System.out.println(e); }
    • SOCKETS IN NACH0S
        How to create an output Stream ?
      • To the server socket using the class PrintStream or DataoutputStream of java.io
      PrintStream output; try { output = new PrintStream (Client.getOutputStream()); } catch (IOException e) { System.out.println(e); }
    • SOCKETS IN NACH0S
        How to close socket?
      • You should always close the output and input stream before you close the socket.
      try { output.close (); input.close (); Client.close(); } catch (IOException e) { System.out.println(e); }