1 / 10

Network Programming

Network Programming. How do Server, Client, and Display applications communicate with each other?. Client. Client. Server. Display. Display. Client. Network Programming in RESOLVE/C++. Unidirectional channels: one application sends, the other receives

ocean
Download Presentation

Network Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Network Programming • How do Server, Client, and Display applications communicate with each other? Client Client Server Display Display Client

  2. Network Programming in RESOLVE/C++ • Unidirectional channels: one application sends, the other receives • Two channels are needed for bi-directional communication (underlying TCP communication links are bi-directional, but RCPP API makes them unidirectional)

  3. Identifying the Receiver • IP address and port number • IP address uniquely determines the computer (e.g., 164.107.112.14).We use the host name (e.g., beta.cis.ohio-state.edu) • Port number is an integer to distinguish connections and services (e.g., ftp uses 21, BugsWorld Server uses 7277)

  4. Connection Protocol • Each receiver application advertises its host name and port number, and “listens” for other applications that want to “connect” • “Sender” application tries to open a connection to “Receiver” application using known host name and port number • When receiver detects sender’s attempt, the connection is established

  5. RESOLVE/C++ API • Sender sends information through Character_OStream • Receiver receives information through Character_IStream • Seamless integration of network programming in the existing RCPP I/O framework!

  6. Opening a Connection: Sender object Character_OStream ochannel; object Text host_name; object Integer port_number; . . . while (not ochannel.Is_Open ()) { // trying to connect to host_name, port_number ochannel.Open_External (host_name, port_number); } . . .

  7. Opening a Connection: Receiver object Character_IStream ichannel; . . . while (not ichannel.Is_Open ()) { // waiting for reverse connection ichannel.Open_External (); } . . .

  8. Receiver: Finding Host Name and Port Number object Character_IStream ichannel; object Text host_name; object Integer port_number; . . . ichannel.Get_Host_And_Port (host_name, port_number); . . .

  9. Communication • Once the connection is established, the sender writes to the output stream, and the receiver reads from the input stream exactly as they would from any input/output stream

  10. Client-Server Protocol • Server advertises host name and port number, then waits for connection from any client. • Client attempts to connect with server using server’s host name and port number. Once connection is established, client can send information to server. So client sends its own host name and port number to server. Then it waits for reverse connection. • Server, having established the connection, reads the client’s host name and port number, and initiates its own attempt at connecting with the client. Since the client is waiting for the server, the reverse connection is established. Now the server can send information to the client.

More Related