Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC364 Lecture 02

CSC364 Lecture 02

Introduction to Networked, Distributed, and Parallel Computing
Sockets
(202601)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

January 07, 2026
Tweet

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 364 Introduction to Networked, Distributed, and Parallel Computing Lecture 02. Sockets 1
  2. 3 Concepts Device A (IP address) 🏭 🏭 🏭 🏭

    Port Port Port Port Port Port Port Port Socket Socket Device B (IP address)
  3. 4 Goal If we can make two programs talk to

    each other, everything else in the course has a place to land.
  4. 5 De f inition A socket is a bidirection a

    l byte stre a m between two processes (progr a ms) Import a nt: • Not mess a ges (text) • Not objects • Just bytes
  5. 6 Why they matters? Sockets a re used everywhere: •

    HTTP servers • Multipl a yer g a mes • Distributed d a t a b a ses • ROS nodes S a me ide a s. Bigger sc a le.
  6. 7 Client - Server Architecture Server 1. Cre a te

    socket 2. Bind to port 3. Listen 4. Accept connection Client 1. Cre a te socket 2. Connect to server 3. Send / receive d a t a
  7. 9 Localhost or 127.0.0.1 loc a lhost A hostn a

    me th a t me a ns this computer 127.0.0.1 The IP a ddress of the loopb a ck interf a ce ➡ Both refer to the s a me m a chine you a re running on
  8. 10 How to Get Your IP Address m a cOS

    / Linux ifcon f ig Look for inet under en0 (Wi-Fi) or en1. Windows (Comm a nd Prompt or PowerShell) ipcon f ig Look for IPv4 Address.
  9. 16 Failure Is Normal Try this: • Kill the server

    • Disconnect the client • Send inv a lid d a t a Common errors: • Connection refused • Timeout
  10. class TheMouseNanny implements MouseListener { public void mousePressed (MouseEvent e)

    { } public void mouseClicked(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseDragged(MouseEvent me) { } public void mouseMoved(MouseEvent e) { } }
  11. // MouseListener public void mousePressed (MouseEvent e) {} public void

    mouseClicked(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseDragged(MouseEvent me) { } public void mouseMoved(MouseEvent e) { } // MouseMotionListener public void mouseDragged(MouseEvent me) { } public void mouseMoved(MouseEvent e) { }
  12. CSC 364 Introduction to Introduction to Networked, Distributed, and Parallel

    Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC 364 at Cal Poly. They cannot be distributed or used for another purpose. 35