1 / 17

Example of A Client and A Server

Example of A Client and A Server. An Example Service. Purpose Count times invoked Return printable ASCII message Connection-oriented protocol Sequential execution (not concurrent). An Example Client. Open TCP connection to server Iterate until end-of-file Receive text

Download Presentation

Example of A Client and A Server

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. Example of A Client and A Server

  2. An Example Service • Purpose • Count times invoked • Return printable ASCII message • Connection-oriented protocol • Sequential execution (not concurrent)

  3. An Example Client • Open TCP connection to server • Iterate until end-of-file • Receive text • Print characters received • Close connection • Exit

  4. Example Server • Create socket and put in passive mode • Iterate forever • Accept next connection, get new socket • Increment count and send text message • Close socket for connection • Notes • Main socket remains open • Server never exits

  5. Socket Calls In Client And Server • Client closes socket after use • Server never closes original socket

  6. Code For Client • Arguments to program • Host • Protocol port • Both optional • Many details • Minor incompatibilities among socket implementations • Unix • Microsoft • Use C #ifdef

  7. Example Client Code (1)

  8. Example Client Code (2)

  9. Example Client Code (3)

  10. Example Client Code (4)

  11. Example Client Code (5)

  12. Code For Server • Arguments to program • Protocol port • C language #ifdefs for socket variants

  13. Example Server Code (1)

  14. Example Server Code (2)

  15. Example Server Code (3)

  16. Example Server Code (4)

  17. Stream Interface • Sender • Calls send repeatedly • Specifies number of octets per call • TCP • Divides stream into segments • Receiver • Calls recv repeatedly • Receives one or more octets per call • Count of zero means ‘‘end of file’’ • Size received unrelated to size sent

More Related