Lecture 21-22: Sockets & Unix I/O Abstractions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering Unix’s file-oriented design, process communication mechanisms, popen, the client/server paradigm, and the essential socket API calls and data structures needed to build networked applications.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards

Everything Is a File

Unix philosophy in which terminals, regular files, pipes, sockets, and many devices are all accessed through the same file-oriented interface.

2
New cards

File Descriptor (fd)

A small integer returned by the kernel that uniquely identifies an open file, pipe, or socket within a process.

3
New cards

Pipe

A unidirectional, in-memory buffer that lets one process write data for another to read, enabling parent/child communication.

4
New cards

Temporary File Buffer

A crude way to connect two independent processes by having one write to a file while the other reads; slow and hard to synchronize.

5
New cards

fopen()

C library call that opens a file on disk and returns a FILE* stream for buffered I/O.

6
New cards

fdopen()

Associates an existing file descriptor with a FILE* stream, allowing buffered I/O on an already-open descriptor.

7
New cards

popen()

Creates a pipe, forks, and runs a shell command, returning a FILE* connected to the child’s stdin ("w") or stdout ("r").

8
New cards

pclose()

Closes the FILE* obtained from popen() and waits for the associated process to terminate.

9
New cards

Interface (in IPC)

The agreed-upon rules—data formats, order of operations, expectations—that two communicating programs must follow.

10
New cards

Client

A program that actively initiates a connection to a server, expecting a service at a specific IP address and port.

11
New cards

Server

A long-running program that waits (listens) passively for incoming client connections on a known port.

12
New cards

Socket

An endpoint for bidirectional communication between processes, usually over a network, treated like a file descriptor.

13
New cards

PFINET / AFINET

Protocol/address family constant indicating an IPv4 Internet socket.

14
New cards

SOCK_STREAM

Socket type that provides reliable, byte-stream service (typically TCP).

15
New cards

SOCK_DGRAM

Socket type that provides connectionless, datagram service (typically UDP).

16
New cards

socket()

System call: int socket(domain, type, protocol); creates a socket and returns its file descriptor.

17
New cards

bind()

System call: int bind(fd, *addr, len); associates a server’s socket with a local address and port.

18
New cards

listen()

System call: int listen(fd, backlog); marks a bound socket as passive, ready to accept incoming connections, with a queue length of backlog.

19
New cards

backlog

The maximum number of pending client connections that can wait in the listen queue before accept().

20
New cards

accept()

System call: int accept(fd, *addr, *len); removes the next pending connection from the listen queue and returns a new socket for data transfer.

21
New cards

connect()

Client-side system call: int connect(fd, *addr, len); actively establishes a connection to a listening server socket.

22
New cards

sockaddr_in

Structure holding IPv4 address (sinaddr), port (sinport), and family (sin_family) information for socket calls.

23
New cards

gethostbyname()

Library function that converts a hostname into an IP address for populating sockaddr_in.

24
New cards

htons()

Function that converts a 16-bit value (e.g., port) from host byte order to network byte order.

25
New cards

read() / write()

Low-level system calls used on socket file descriptors to receive and transmit raw bytes.

26
New cards

IP Address

Numeric identifier (e.g., 192.168.1.5) that locates a host on an IP network; multiple sockets can share one IP.

27
New cards

Port Number

16-bit value identifying a specific application endpoint on a host; many hosts may use the same port for the same service type.

28
New cards

dup2()

System call that duplicates one file descriptor onto another, often redirecting a socket to stdin/stdout in forked processes.

29
New cards

execl()

exec-family call that replaces the current process image with a new program, inheriting existing file descriptors.

30
New cards

Fork-and-Delegate Web Server

Server model in which the listener process accepts a connection, forks, redirects the socket in the child, and execs a worker program so the parent can immediately handle new clients.