Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering Recitation 2 Suhit Gupta. Today we will be covering… XML II Sockets, Server – Client relationships, Servers capable of handling multiple.

Similar presentations


Presentation on theme: "Software Engineering Recitation 2 Suhit Gupta. Today we will be covering… XML II Sockets, Server – Client relationships, Servers capable of handling multiple."— 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

5 XML – minOccurs/maxOccurs Adding Attributes to the Inline Type Definition

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. minOccurs maxOccurs

7 XML – Attribute groups Adding Attributes Using an Attribute Group.

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 Nested Choice and Sequence Groups

10 XML – Choice and Sequence [II] A choice group element allows only one of its children to appear in an instance. choice 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.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 code The server calls on the Multiserver part – The codeThe code

19 Parse this Stream/File The code from Recitation 1 is one example Here is another The code The code

20 Conclusion That should be it… questions???


Download ppt "Software Engineering Recitation 2 Suhit Gupta. Today we will be covering… XML II Sockets, Server – Client relationships, Servers capable of handling multiple."

Similar presentations


Ads by Google