UTPA STEM/CBI Courses/Computer Networks/Socket Programming

From Wikiversity
Jump to navigation Jump to search

Course Title: Computer Networks

Lecture Topic: Socket Programming

Instructor: Fang Liu

Institution: University of Texas - Pan American

Backwards Design[edit | edit source]

Course Objectives

  • Primary Objectives- By the next class period students will be able to:
    • Build a client/server networking program with TCP/IP socket programming
  • Sub Objectives- The objectives will require that students be able to:
    • Understand the concept of a client-server model
    • Understand how to identify communicating processes
    • Understand the differences in TCP and UDP
    • Understand how to request a port number and find out what the assigned port number is.
    • Understand the existence of different data representation formats in different computer systems and the necessity to convert to the standard form before sending out data onto the internet.
  • Difficulties- Students may have difficulty:
    • Allowing a server to accept multiple clients
    • Sending message to multiple clients.
  • Real-World Contexts- There are many ways that students can use this material in the real-world, such as:
    • Online/networking chatting programs are used every day. Examples include msn messenger, yahoo messenger, etc. Students will have a better understanding of the client-server model, the TCP/UDP transport protocols, BSD socket programming after building their own conferencing programs.

Model of Knowledge

  • Concept Map
    • Identification of processes with sockets.
    • Understanding sockets are the interface to call for transport layer services.
    • Understanding the functions supported by transport layer.
    • Understanding the difference between TCP and UDP transport service.
  • Content Priorities
    • Enduring Understanding
      • Understand how to establish client/server communications with socket programming.
    • Important to Do and Know
      • Become familiar with BSD sockets.
    • Worth Being Familiar with
      • Understand the client/server communication model.

Assessment of Learning

  • Formative Assessment
    • In Class (groups)
      • Discussion of the client/server model.
      • Discussion of the identification of processes with sockets.
      • Discussion of the difference between TCP and UDP.
    • Homework (individual)
      • Development of a simple TCP-based client/server communication system.
      • Internet based search of existent client/server applications developed with BSD sockets.
  • Summative Assessment
    • Group discussion the conclusions.

Legacy Cycle[edit | edit source]

OBJECTIVE

By the next class period, students will be able to:

  • Understand how to call BSD sockets to enable the communication between clients and servers.

The objectives will require that students be able to:

  • Explain how the web messengers (e.g. msn, yahoo, google talk, etc.) allow the communications among online users.

THE CHALLENGE

Suppose you are required to build a conferencing program (like msn/yahoo messenger) that enables conversation between multiple conference users. All the connected users can receive all the messages transmitted by any of the users. The group communication is facilitated by a conference server. A user sends a message to the server, and the server relays that text to all the other clients. Each user receives the text relayed by the server and displays it on the screen. How would you do it?

GENERATE IDEAS

  • Students will investigate one of the popular web messengers and how it works.
  • Students will investigate how to request a socket port number and identify a socket.
  • Students will investigate how to allow a server to listen to multiple clients.

MULTIPLE PERSPECTIVES

Students will discuss their ideas through brain storming before developing their own web programs.

RESEARCH & REVISE

Once data is collected, students will discuss their methods in developing their own conferencing programs and draw conclusions.

TEST YOUR METTLE

Students will compare their results against their peers’ observations and conclusions.

GO PUBLIC

Students will discuss their results among themselves and in front of the class.

Test Your Mettle Quiz[edit | edit source]

True or False?

  1. Sockets provide an application programming interface (API) for the TCP/IP protocol stack.
  2. Sockets allow the delivery of incoming data packets to the appropriate application process or thread based on a combination of local and remote IP addresses and port numbers.
  3. A process associates with a particular port to send and receive data.
  4. A socket is created by the process and bound to a socket address which consists of a combination of a port number and an IP address.
  5. A port number is a 32-bit unsigned integer.
  6. High port numbers are usually used by applications implementing common services.
  7. The port number of a server is usually publicly known, while the clients need to notify the server about their port numbers.
  8. Stream sockets, also known as connectionless sockets, use User Datagram Protocol (UDP).
  9. Datagram sockets, also known as connection-oriented sockets, use Transmission Control Protocol (TCP) or Stream Control Transmission Protocol (SCTP).
  10. A TCP server may not serve several clients concurrently.
  11. UDP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer.
  12. TCP is a connectionless protocol with no guarantee of delivery.
  13. A blocking socket will not return control until it has sent (or received) all data specified for the operation.
  14. Socket() creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it.
  15. Bind() is typically used on the client side, and associates a socket with a socket address structure, i.e. a specified local port number and IP address.
  16. Listen() is used on the client side, and causes a bound TCP socket to enter listening state.
  17. Connect() is used on the client side, and assigns a free local port number to a socket.
  18. Accept() is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection.
  19. Close() causes the system to release resources allocated to a socket. In case of TCP, the connection is terminated.
  20. Select() is used to prune a provided list of sockets for those that are ready to read, ready to write or have errors.