1 / 11

ITEC 350 Homework 2

ITEC 350 Homework 2. Socket Programming. API available to programs. Application Programming Interface (API) to TCP & UDP “Sockets” Two Modes: Datagram (DGRAM) Stream (INET) A socket is defined by an IP address and a port number. Application Program. Stream. Dgram.

tanner-hull
Download Presentation

ITEC 350 Homework 2

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. ITEC 350 Homework 2 Socket Programming

  2. API available to programs • Application Programming Interface (API) to TCP & UDP • “Sockets” • Two Modes: • Datagram (DGRAM) • Stream (INET) • A socket is defined by an IP address and a port number Application Program Stream Dgram TCP | UDP Transport Layer

  3. Socket Programming – HW02 • Writing programs in Java can give students great insight into sockets, IP addresses, ports, etc. • If you have had ITEC 120/220 • Then you know all about java stream io (BufferedReader, BufferedWriter) • All you need is java.net package • If you have _not_ had ITEC 120/220 • you may use a programming language like C, C++, etc. • Or, if you have had no programming language that supports sockets, come see me in office hours.

  4. java.net • The “real” .net … not that other M$.NET • Packages: what Java calls collections of classes • .net is a package – containing classes: • Socket, ServerSocket for TCP streams • DatagramSocket for UDP datagrams

  5. Server Client Create a ServerSocket object for port 4444 Open a connection on port 4444 Using ServerSocket.accept, wait for a client to open a connection Wait for user to type something If user types only CR, exit else When a client opens a connection, the accept method has returned a copy of the client socket. Create a BufferedReader for this object. Using getOutputStream() method create PrintWriter object. Send client text to server Wait for server response Wait for client to type something Echo server response to cmdwin for client Echo client text to cmdwin for server. Accept server response from keyboard Send server text over socket to client • We will implement the following flowcharts

  6. ServerSocket class

  7. Socket Class

  8. DatagramSocket class

  9. Related classes

  10. Note • this is *NOT* the standard Echo server that is widely found on the web. • You must have echo going in both directions. • Java Programming, but as a last resort C or C++ • If you only know C, C++ • Let me know via email

  11. Submission • Save your source codes and a ReadMe.doc file to RU03 folder of your dropbox • The ReadMe.doc file must include: • Your name • File names of your source codes and descriptions of each files. • Executing Instruction • Length: Less than 3 pages

More Related