We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byGunnar Wedgeworth
Modified over 2 years ago
Lecture 2b Sockets Erick Pranata © Sekolah Tinggi Teknik Surabaya 1
» Do not have to “connect“ before sending messages » Preserve message boundaries » Best effort: message may lose, may scrambled 2 © Sekolah Tinggi Teknik Surabaya
» Efficiency ˃Single request message and single response message » Flexibility ˃Minimal overhead platform 3 © Sekolah Tinggi Teknik Surabaya
UdpClient.Send()UdpClient.Receive() 5 © Sekolah Tinggi Teknik Surabaya
packet from A packet from B packet from A 6 © Sekolah Tinggi Teknik Surabaya
7 » Maximum message length: 65,507 bytes (65 KB)
» Construct an instance of UdpClient, optionally specifying the local address and port. » Communicate by sending and receiving datagrams (byte arrays) using the Send() and Receive() methods of UdpClient. » When finished, deallocate the socket using the Close() method of UdpClient. 8 © Sekolah Tinggi Teknik Surabaya
» Construct an instance of UdpClient, specifying the local port. The server is now ready to receive datagrams from any client. » Receive a packet using the Receive() method of UdpClient. The Receive() method takes a reference to an IPEndPoint instance as an argument, and when the call returns the IPEndPoint contains the client’s address so we know where to send the reply. » Communicate by sending and receiving datagram packets using the Send() and Receive() methods of UdpClient. » When finished, deallocate the socket using the Close() method of UdpClient. 9 © Sekolah Tinggi Teknik Surabaya
» Call the Socket constructor: The constructor specifies the address type, socket type, and protocol type. » Call the Socket Connect() method: Connect() takes an IPEndPoint argument that represents the server to connect to. » Send and receive data: Using the Socket Send() and Receive() calls. » Close the socket: Using the Socket Close() method. 11 © Sekolah Tinggi Teknik Surabaya
» Call the Socket constructor: The constructor specifies the address type, socket type, and protocol type. » Call the Socket Bind() method: Bind() associates the socket with a local address and port number. » Call the Socket Listen() method: Listen() takes an integer argument representing the number of connections allowed to queue, and starts listening for incoming connections. » Repeatedly: ˃ Call the Socket Accept() method to accept an incoming connection: Accept() takes no arguments and returns a Socket instance representing the remote client socket. ˃ Receive and send data: Using the accepted client Socket instance, use its Receive() and Send() methods to transfer data. ˃ Close the client socket: Using the Socket Close() method. » Close the socket: Using the Socket Close() method. 12 © Sekolah Tinggi Teknik Surabaya
» Socket Options.pdf Socket Options.pdf 13 © Sekolah Tinggi Teknik Surabaya
» Send the echo string to the server. » Block on Receive() for up to three seconds, starting over (up to five times) if the reply is not received before the timeout. » Terminate the client. 14 © Sekolah Tinggi Teknik Surabaya
» int len = s.Receive(buf, 0, buf.Length, SocketFlags.Peek); » len = s.Receive(buf, 0, buf.Length, SocketFlags.None); 15 © Sekolah Tinggi Teknik Surabaya
» Answer these and write it into an essay.these » Submission due: Tuesday, 1 April 2014 (printed) 16 © Sekolah Tinggi Teknik Surabaya
» David Makofske, Michael J. Donahoo, Kenneth L. Calvert, TCP/IP Sockets in C#: Practical Guide for Programmers, Morgan Kaufmann, 2004 17 © Sekolah Tinggi Teknik Surabaya
Lecture 1 Overview of Socket Programming Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Chapter 2 Applications and Layered Architectures Sockets.
Socket programming with UDP UDP: no “connection” between client & server sender explicitly attaches IP destination address and port # to each packet receiver.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
Fall 2000Datacom 11 Socket Programming Review Examples: Client and Server-Diagnostics UDP versus TCP Echo.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Socket Programming. Introduction Sockets are a protocol independent method of creating a connection between processes. Sockets can be either – Connection.
Data Communications and Networking (Third Edition)
1 Dimension of Server Designs r Iterative vs Concurrent r Connection-oriented vs. connectionless r Stateful and stateless m Constrained by application.
1 ELEN 602 Lecture 15 More on IP TCP. 2 byte stream Send buffer segments Receive buffer byte stream Application ACKs Transmitter Receiver TCP Streams.
Introduction to Sockets Jan Why do we need sockets? Provides an abstraction for interprocess communication.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn: To understand Java networking with URLs, sockets and datagrams. To implement Java.
TCP/IP Sockets in Java: Practical Guide for Programmers Kenneth L. Calvert Michael J. Donahoo.
1 Network Communications A Brief Introduction. 2 Network Communications.
The Socket Interface Chapter 22. Introduction This chapter reviews one example of an Application Program Interface (API) which is the interface between.
Position of application layer. Application layer duties.
Windows Programming Using C# Internet Programming.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
© 2017 SlidePlayer.com Inc. All rights reserved.