复旦大学:《计算机网络 Computer Networking》课程实验指导_因特网中继聊天(IRC)服务器_socketProgramming-Part1

Socket Programming Part 1 ZhuZhu 07302010096@fudan.edu.cn Reference: Daniel Spangenberger 15-441 Computer Networks, Fall 2007 PPT-4 Socket Programming
Zhu Zhu 07302010096@fudan.edu.cn Reference: Daniel Spangenberger 15-441 Computer Networks, Fall 2007 PPT-4 Socket Programming

Why Do I Want Networking? Goal of Networking: Communication Share data Pass Messages Say I want to talk to a friend in Singapore How can i do this? What applications and services must I use Where can I access them? How will the data get there? Will it be reliable?
Goal of Networking: Communication Share data Pass Messages Say I want to talk to a friend in Singapore… How can I do this? What applications and services must I use? Where can I access them? How will the data get there? Will it be reliable?

Lecture Today. o Motivations for sockets o What's in a socket? o Working with Sockets Concurrent Network Applications
Motivations for Sockets What’s in a Socket? Working with Sockets Concurrent Network Applications

Layered Commuication Application Application Application Presentation Presentation End-to-end Transparency Session Session CPI Transport UDP Transport Network P Network Network Data Link 8023 Data Link WiFi Data Link sica Physical Physical Core Network
Application Presentation Session Transport Network Data Link Physical Application Presentation Session Transport Network Data Link Physical Network Data Link Physical Core Network End-to-end Transparency Application IP IP TCP/ UDP 802.3 WiFi

What's really going on.. Lets consider project one. Client(mIRO) (IRO 128.2194242:6262 TCP 128.2237.25:6667 Which Is IP Packet IP Packet IP Packet IP Packet 1 # Which Is Ethernet Ethernet Ethe Ethe Frame #1 Frame #2 Frame Frame#4
Let’s consider project one… Client (mIRC) 128.2.194.242:6262 Server (IRC) 128.2.237.25:6667 TCP IP Packet #1 IP Packet #2 IP Packet #3 IP Packet #4 Ethernet Frame #1 Ethernet Frame #2 Ethernet Frame #3 Ethernet Frame #4 Which Is also… Which Is also…

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

Step One: Socket-time Both the client and server need to setup the socket int socket (int domain, int type, int protocol) ● Domain AF INET(IPv4, also IPv6 available) Type SOCK STREAM TCP SOCK DGRAM UDP ● Protoco 0 int sockfd socket(AF INET, SOCK STREAM, 0)i
Both the client and server need to setup the socket int socket(int domain, int type, int protocol) Domain AF_INET (IPv4, also IPv6 available) Type SOCK_STREAM TCP SOCK_DGRAM UDP Protocol 0 int sockfd = socket(AF_INET, SOCK_STREAM, 0);
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 复旦大学:《计算机网络 Computer Networking》课程实验指导_因特网中继聊天(IRC)服务器_Network Project1 Request 2013.pdf
- 《计算机网络》课程教学资源(参考文献)MACAW_A Media Access Protocol for Wireless LAN’s.pdf
- 《计算机网络》课程教学资源(参考文献)Interdomain Internet Routing.pdf
- 《计算机网络》课程教学资源(参考文献)END-TO-END ARGUMENTS IN SYSTEM DESIGN.pdf
- 《计算机网络》课程教学资源(参考文献)Analysis and Simulation of a Fair Queueing Algorithm.pdf
- 《计算机网络》课程教学资源(参考文献)The Design Philosophy of the DARPA Internet Protocols.pdf
- 《计算机网络》课程教学资源(参考文献)Automated Worm Fingerprinting.pdf
- 《计算机网络》课程教学资源(参考文献)How to 0wn the Internet in Your Spare Time.pdf
- 《计算机网络》课程教学资源(参考文献)A DoS-limiting Network Architecture.pdf
- 《计算机网络》课程教学资源(参考文献)Hash-Based IP Traceback.pdf
- 《计算机网络》课程教学资源(参考文献)Internet Indirection Infrastructure.pdf
- 《计算机网络》课程教学资源(参考文献)Middleboxes No Longer Considered Harmful.pdf
- 《计算机网络》课程教学资源(参考文献)Democratizing content publication with Coral.pdf
- 《计算机网络》课程教学资源(参考文献)Development of the Domain Name System(DNS).pdf
- 《计算机网络》课程教学资源(参考文献)A Scalable Peer-to-peer Lookup Service for Internet Applications.pdf
- 《计算机网络》课程教学资源(参考文献)LOOKING UP DATA in P2P Systems.pdf
- 《计算机网络》课程教学资源(参考文献)Making Gnutella-like P2P Systems Scalable.pdf
- 《计算机网络》课程教学资源(参考文献)Resilient Overlay Networks.pdf
- 《计算机网络》课程教学资源(参考文献)An End-to-End Approach to Host Mobility.pdf
- 《计算机网络》课程教学资源(参考文献)MOBILE NETWORKING THROUGH MOBILE IP.pdf
- 复旦大学:《计算机网络 Computer Networking》课程实验指导_因特网中继聊天(IRC)服务器_socketProgramming-Part2.pptx
- 复旦大学:《计算机网络 Computer Networking》课程实验指导_因特网中继聊天(IRC)路由_project 2 IRC routing.pptx
- 复旦大学:《计算机网络 Computer Networking》课程实验指导_拥塞控制_project3_2013.pdf
- 复旦大学:《计算机网络 Computer Networking》课程实验指导_拥塞控制_project3-congestion_control.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)01 Introduction.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)02 Protocol Stacks and Layering.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)03 Design Philosophy & Applications.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)04 Socket Programming.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)05 physical_Transmission.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)06 Physical Layer(Cont)& Data Link Layer.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)07 Ethernet.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)08 Software School.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)09 IP Packets.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)10 Intra-Domain Routing.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)11 Multicast.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)12 Inter-Domain Routing BGP(Border Gateway Protocol).ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)13 DNS.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)14 ip-grab-bag(IP Wrap up).ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)15 Virtual Circuits, ATM, MPLS.ppt
- 复旦大学:《计算机网络 Computer Networking》课程电子教案(PPT课件讲稿)16 Transport Protocols.ppt