網路程式設計 - C# 版 日期 : 2018/12/4.

Slides:



Advertisements
Similar presentations
1 Android Introduction Hello Threads. 2 Goal Create an application that uses a background thread as a UDP server to receive messages from the UDP client.
Advertisements

Multiplexing/Demux. CPSC Transport Layer 3-2 Multiplexing/demultiplexing application transport network link physical P1 application transport network.
Lecture 2b Sockets Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
Referring to Java API Specifications
Network Programming 授課教師 : 詹益禎 中文課名 : 網路程式設計 學分時數 : 3 學分\ 3 小時 助教 : 李宏杰、趙振宣 教室 : 上課時間 : 9:05~12:00 (Wed.)
Socket Programming.
Windows Processing Design
1 Java Networking – Part I CS , Spring 2008/9.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
網路程式設計 簡易網路程式 2. 簡易線上溝通程式 3. 網路應用程式 4.Servlet 程式設計 5.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
1 Network Layers Application Transport Network Data-Link Physical bits.
Datagram Programming A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.
Julia Ljunbjörk and Anita Mugenyi. What is a socket? Like a house Between the layers.
JAVA Socket Programming Source: by Joonbok Lee, KAIST, 2003.
Network Programming 授課教師 : 詹益禎 中文課名 : 網路程式設計 學分時數 : 3學分\3小時 助教 :許聖宏
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
CS4273: Distributed System Technologies and Programming I Lecture 5: Java Socket Programming.
Network Layer Programing Connection-Oriented Sockets SWE 344 Internet Protocols & Client Server Programming.
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Winter 2002Suprakash Datta1 Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
-1- Georgia State UniversitySensorweb Research Laboratory CSC4220/6220 Computer Networks Dr. WenZhan Song Associate Professor, Computer Science.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
Socket Programming Lee, Sooyong
UDP vs TCP UDP Low-level, connectionless No reliability guarantee TCP Connection-oriented Not as efficient as UDP.
Socket Programming Tutorial. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
Object Oriented Programming in Java Lecture 16. Networking in Java Concepts Technicalities in java.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
UDP Client-Server. The Socket Class The Socket class provides a set of methods and properties for network communications. The Socket class allows you.
Remote Shell CS230 Project #4 Assigned : Due date :
Java Socket programming. Socket programming with TCP.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Socket-Programming.  Establish contact (connection).  Exchange information (bi-directional).  Terminate contact.
Introduction to Sockets “A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port.
Network Programming with C# Exceed Camp #2, CPE, KU Day 3.
Connectionless Sockets SWE 344 Internet Protocols & Client Server Programming.
Slides for Chapter 4: Interprocess Communication From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, © Addison-Wesley.
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
IP multicasting SWE 344 Internet Protocols & Client Server Programming.
1 CSCD 330 Network Programming Spring 2014 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 7 Application.
12/5/2015.net 1 system.net Contains any network functionallity you would need in c# Several sub namespaces exists to allow for more fined control –System.Net.Sockets.
Client/Server Socket Programming Project
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
Java Programming II Java Network (I) Java Programming II.
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.
Lab 1 Introduction MMLAB. Environment Install Linux OS in a computer( VirtualBox or Vmware or Native) It’s all up to you for selecting Ubuntu Server or.
CLIENT (Browser) socket accept C1 C2 recv C2 recv send C2 send end_thread recv C3 send bind connect Web Server Proxy recv close C3 close C2 end_thread.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Network Programming Communication between processes Many approaches:
Socket Programming Ameera Almasoud
Object-Orientated Analysis, Design and Programming
Socket Programming Socket Programming Overview
Socket Programming Cal Poly Pomona Young CS380.
Network Programming Introduction
Socket programming with TCP
Sockets.
Chapter 2: outline 2.1 principles of network applications
CSCD 330 Network Programming
Socket Programming Socket Programming Overview
Socket Programming.
CSCD 330 Network Programming
Socket Programming 2: Application Layer.
CPSC 441 UDP Socket Programming
Chapter 2: Application layer
Multiplexing/Demux.
Socket Programming with UDP
Review Communication via paired sockets, one local and one remote
Presentation transcript:

網路程式設計 - C# 版 日期 : 2018/12/4

簡單的網路層次圖 TCP : Socket, ServerSocket UDP : DatagramSocket, DatagramPacket IP : InetAddress, URL 2 陳鍾誠 - 2018/12/4

詳細的網路層次圖 URL Socket ServerSocket DatagramSocket DatagramPacket InetAddress 3 陳鍾誠 - 2018/12/4

Socket 程式設計模型 Request 請求 Client Server Response 回覆 4 陳鍾誠 - 2018/12/4

C# Socket Programming IP: Socket (插座) : IPEndPoint TCP socket : Socket  TCP Client ServerSocket  TCP Server UDP Socket : DatagramSocket  Udp Client , Udp Server DatagramPacket  Udp packet 5 陳鍾誠 - 2018/12/4

TCP Socket Programming Connect() Receive() Send() Close() Server 同樣是用 Socket 物件 Bind() Listen() Accept() RemoteEndPoint 6 陳鍾誠 - 2018/12/4

最簡單的 Client-Server 網路程式 IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(args[0]), 20); Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); server.Connect(ipep); while(true) { string input = Console.ReadLine(); if (input == "exit") break; byte[] data = Encoding.ASCII.GetBytes(input); server.Send(data); } Console.WriteLine("Disconnecting from server..."); server.Shutdown(SocketShutdown.Both); server.Close(); IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 20); Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); newsock.Bind(ipep); newsock.Listen(10); while(true) { Socket client = newsock.Accept(); IPEndPoint clientep = (IPEndPoint) client.RemoteEndPoint; // create a new thread and then receive message. TcpListener listener = new TcpListener(client); Thread thread = new Thread(new ThreadStart(listener.run)); thread.Start(); } public class TcpListener { … public void run() { while (true) byte[] data = new byte[1024]; int recv = socket.Receive(data); if (recv == 0) break; Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); } 7