Which is easier? An application programmer(writing an IRC server) Doesn't need to send iP packets Doesn't need to send ethernet frames Doesn't need to worry about reliability Shouldn't have to Sockets do this! TCP streams UDP packetized service(Project 2) You'll be doing this! (using sockets) To share data To pass messages
An application programmer (writing an IRC server) Doesn’t need to send IP packets Doesn’t need to send Ethernet frames Doesn’t need to worry about reliability Shouldn’t have to! Sockets do this! TCP streams UDP packetized service (Project 2) You’ll be doing this! (using sockets) To share data To pass messages
What's in a Socket Some information needed Where is the remote machine? IP Address Hostname (resolved to IP) Which service do i want? Port ● After that You get a file! A plain old file As simple as other Unix I/O Don't forget to close it when you're done
Some information needed… Where is the remote machine? IP Address Hostname (resolved to IP) Which service do I want? Port After that… You get a file! A plain old file! As simple as other Unix I/O Don’t forget to close it when you’re done!
How do i do it? Request a socket descriptor Both the client and the server need to Bunch of kernel allocations e And the server Binds to a port I am offering a service on port x. hear me roar Listens to the socket a“Hey! Say something: Accepts the incoming connection Good, you spoke up!” ● And the client Connects “ I'm interested!
Request a socket descriptor Both the client and the server need to Bunch of kernel allocations… And the server… Binds to a port “I am offering a service on port x. Hear me roar” Listens to the socket “Hey! Say something!” Accepts the incoming connection “Good, you spoke up!” And the client… Connects “I’m interested!
Sockets: The lifecycle Client Server socket socket o bind( listen( connect( Connection Request accept( write( read( Client/ Server Session read( write() close() EOF reado close()
Client Server socket() connect() write() read() close() socket() bind() listen() accept() write() read() close() EOF read() Connection Request Client / Server Session