1 / 20

Software Engineering

Software Engineering. Recitation 2 Suhit Gupta. Today we will be covering…. XML II Sockets, Server – Client relationships, Servers capable of handling multiple clients. XML - Elements. Elements are capable of taking on several values –

deiondre
Download Presentation

Software Engineering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Engineering Recitation 2 Suhit Gupta

  2. Today we will be covering… • XML II • Sockets, Server – Client relationships, Servers capable of handling multiple clients.

  3. XML - Elements • Elements are capable of taking on several values – • string boolean float double decimal timeInstant timePeriod month year century recurringDate recurringDay timeDuration recurringDuration binary uriReference ID IDREF ENTITY NOTATION language IDREFS ENTITIES NMTOKEN NMTOKENS Name QName NCName integer nonPositiveInteger negativeInteger long int short byte nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte positiveInteger date time • And on and on and on and on….. • Read the primer 0 for more and in depth information

  4. XML – values • <xsd:simpleType name="MyInteger" base="xsd:integer"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="99"/> </xsd:simpleType> • <xsd:simpleType name="Sku" base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:simpleType>

  5. XML – minOccurs/maxOccurs

  6. XML – max/min [II] • You can specify max and min values • By combining and nesting the various groups provided by XML Schema, and by setting the values of minOccurs and maxOccurs, it is possible to represent any content model expressible with an XML.

  7. XML – Attribute groups

  8. XML Attribute groups [II] • Using an attribute group in this way can improve the readability of schema, and facilitates updating schema because an attribute group can be defined and edited in one place and referenced in multiple definitions and declarations. • These characteristics of attribute groups make them similar to parameter entities in XML

  9. XML – Choice and Sequence

  10. XML – Choice and Sequence [II] • A choice group element allows only one of its children to appear in an instance. • Un-named groups of elements can be constrained so that only one of the elements may appear in an instance. • Alternatively, they can also be defined, and along with elements in named groups, they can be constrained to appear in the same order (sequence) as they are declared.

  11. XML - Conclusion • I think that should be it on XML. • Any more info… read about it on the web • XML Primer 0 - http://www.w3.org/TR/2000/WD-xmlschema-0-20000407/ • http://www.w3schools.com

  12. Network basics • link: connection between components, including wireless => point-to-point (modem), multiple access (Ethernet) • router, switch: forward packets • node: router (= intermediate system), host (= end system) • clients: access resources and services • servers: provide resources and services (may also be client) • dumb terminal: no local processing

  13. Firewalls • computer between internal (“intranet”) and external network • = policy-based packet filtering • watch single point rather than every PC • limit in/out services, restrict incoming packets • can’t prevent people walking out with disks • packet filter: restrict IP addresses (address filtering), ports • connection filter: only allow packets belonging to authorized (TCP) connections • encrypted tunnel: tunnel = layer same layer inside itself à virtual network: connect • intranets across Internet • NA(P)T: network address (and port) translator are not firewalls, but can prevent all • incoming connections

  14. NAT

  15. Sockets • What are ports? • What are sockets? • What is the difference?

  16. Simple Client – Janak Parekh import java.net.*; import java.io.*; public class client { public static void main(String[] args) { try { Socket s = new Socket("128.59.209.243",2099); BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter pw = new PrintWriter(s.getOutputStream()); /* The following comment does not work as intended--Java is too clever * about connections, so this line gets printed immediately */ // System.out.println("Connected to server, talking"); pw.println("Hello"); pw.flush(); // Now wait for something back String st = br.readLine(); System.out.println(st); // Clean up s.close(); } catch(Exception e) { e.printStackTrace(); } } }

  17. Simple Server – Janak Parekh import java.net.*; import java.io.*; public class server { public static void main(String[] args) { try { ServerSocket s = new ServerSocket(2099); while(true) { Socket t = s.accept(); BufferedReader br = new BufferedReader(new InputStreamReader(t.getInputStream())); PrintWriter pw = new PrintWriter(t.getOutputStream()); // Wait for hello String st = br.readLine(); System.out.println("I got " + st + ", I'm going to send something back"); Thread.sleep(5000); // Now respond pw.println("Hey, how are you!?"); pw.flush(); // Close the connection t.close(); } } catch(Exception e) { e.printStackTrace(); } } }

  18. Multithreaded Server • A Multithreaded Server – The code • The server calls on the Multiserver part – The code

  19. Parse this Stream/File • The code from Recitation 1 is one example • Here is anotherThe code

  20. Conclusion • That should be it… questions???

More Related