<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.terasic.com.tw/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.terasic.com.tw/wiki/index.php?action=history&amp;feed=atom&amp;title=DE10_Advance_revC_demo%3A_Network_Socket</id>
		<title>DE10 Advance revC demo: Network Socket - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.terasic.com.tw/wiki/index.php?action=history&amp;feed=atom&amp;title=DE10_Advance_revC_demo%3A_Network_Socket"/>
		<link rel="alternate" type="text/html" href="http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;action=history"/>
		<updated>2026-04-28T19:33:48Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.5</generator>

	<entry>
		<id>http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2499&amp;oldid=prev</id>
		<title>Bingxia at 09:41, 27 August 2018</title>
		<link rel="alternate" type="text/html" href="http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2499&amp;oldid=prev"/>
				<updated>2018-08-27T09:41:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 09:41, 27 August 2018&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Client and Server communication.jpg|400px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Client and Server communication.jpg|400px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::Figure 3-12 Client and Server communication&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::Figure 3-12 Client and Server communication&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The steps involved in establishing a socket on the client side are as follows:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The steps involved in establishing a socket on the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;client&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;side are as follows:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Create a socket with the socket() system call&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Create a socket with the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;socket()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Connect the socket to the address of the server using the connect() system call&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Connect the socket to the address of the server using the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;connect()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Send and receive data. There are a number of ways to do this, but the simplest is to use the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;read()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;write()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system calls.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The steps involved in establishing a socket on the server side are as follows:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The steps involved in establishing a socket on the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;server&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;side are as follows:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Create a socket with the socket() system call&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Create a socket with the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;socket()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Bind the socket to an address using the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;bind()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call. For a server socket on the Internet, an address consists of a port number on the host machine.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Listen for connections with the listen() system call&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Listen for connections with the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;listen()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Accept a connection with the accept() system call. This call typically blocks until a client connects with the server.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Accept a connection with the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;accept()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system call. This call typically blocks until a client connects with the server.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Send and receive data. There are a number of ways to do this, but the simplest is to use the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;read()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;write()&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;system calls.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Example Code Explanation=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Example Code Explanation=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The example design contains two projects. One is socket server project, and one is socket client project. The SOCK_STREAM socket type is used in the design. The Linux Socket Library is used to provide socket functions, so remember to include the socket API header file – socket.h.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The example design contains two projects. One is socket server project, and one is socket client project. The SOCK_STREAM socket type is used in the design. The Linux Socket Library is used to provide socket functions, so remember to include the socket API header file – socket.h. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br/&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The major function of socket server program is to create a socket server based on the given port number and waiting a client to request to establish a connection. When a connection is established, the server is waiting for an incoming text message. When a message is received, it will show the receiver message on the console terminal, then send the message “I got your message” to the client socket, and then close the server program. Figure 3-13 shows the socket relative code statement. In the program, socket API is used to create a SOCK_STREAM socket, bind API is used to bind the socket to any incoming address and a specified port number. For connection, listen API is used to make the socket as a passive socket that is, as a socket that will be used to accept the incoming connection, and accept API is used to accept the incoming connection. The accept blocks until a client connects with the server. Data receiving and sending is implemented by the read and write API, and close is used to close the socket. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The major function of socket server program is to create a socket server based on the given port number and waiting a client to request to establish a connection. When a connection is established, the server is waiting for an incoming text message. When a message is received, it will show the receiver message on the console terminal, then send the message “I got your message” to the client socket, and then close the server program. Figure 3-13 shows the socket relative code statement. In the program, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;socket&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to create a SOCK_STREAM socket, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;bind&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to bind the socket to any incoming address and a specified port number. For connection, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;listen&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to make the socket as a passive socket that is, as a socket that will be used to accept the incoming connection, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;accept&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to accept the incoming connection. The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;accept&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;blocks until a client connects with the server. Data receiving and sending is implemented by the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;read&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;write&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;close&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;is used to close the socket. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Socket Server Code.jpg|450px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Socket Server Code.jpg|450px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::::Figure 3-13 Socket Server Code&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::::Figure 3-13 Socket Server Code&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The major function of the socket client program is to create a connection based on given hostname (or IP address) and host port. When a connection is established, it will show “Please enter the message: ” message on console terminal to ask users to input a message. After get user’s input message, the message is sent to a remote socket server via the socket. If the remote server socket received the message, it will return a message “I got the message”. The client program will show the received message on the console terminal and exit the program. Figure 3-14 shows the socket relative code statement. In the program, socket API is used to create a SOCK_STREAM socket, connect API is used to connect the remove socket sever based on the given hostname (or IP4v Address) and port number. Data receiving and sending is implemented by read and write API, and close is used to close the socket.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The major function of the socket client program is to create a connection based on given hostname (or IP address) and host port. When a connection is established, it will show “Please enter the message: ” message on console terminal to ask users to input a message. After get user’s input message, the message is sent to a remote socket server via the socket. If the remote server socket received the message, it will return a message “I got the message”. The client program will show the received message on the console terminal and exit the program. Figure 3-14 shows the socket relative code statement. In the program, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;socket&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to create a SOCK_STREAM socket, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;connect&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API is used to connect the remove socket sever based on the given hostname (or IP4v Address) and port number. Data receiving and sending is implemented by &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;read&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;write&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;API, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;close&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;is used to close the socket.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Socket Client Code.jpg|550px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Socket Client Code.jpg|550px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-14 Socket Client Code&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-14 Socket Client Code&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Demonstration Source Code=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Demonstration Source Code=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The source code of the design example is located in the Demonstration folder asshown in Figure 3-15. The Demonstration folder contains three platform subfolders: arm, linux and windows. The project under the arm folder is designed for SoC FPGA board. The project under linux folder is designed for Linux running on Linux PC. The project under windows folder is designed for SoC EDS Shell running on Windows PC. Each platform subfolder contains socket_client and socket_server project folders.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The source code of the design example is located in the Demonstration folder asshown in Figure 3-15. The Demonstration folder contains three platform subfolders: &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;arm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;linux&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;windows&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;. The project under the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;arm&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;folder is designed for SoC FPGA board. The project under &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;linux&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;folder is designed for Linux running on Linux PC. The project under &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;windows&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;folder is designed for SoC EDS Shell running on Windows PC. Each platform subfolder contains socket_client and socket_server project folders.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Source Code Folder Tree.jpg|150px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::[[File:Source Code Folder Tree.jpg|150px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::Figure 3-15 Source Code Folder Tree&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::Figure 3-15 Source Code Folder Tree&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 44:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 44:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Demonstration Setup=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=Demonstration Setup=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here we show the procedure to execute the socket client-server communication demonstration. In this setup procedure, the server program is running to Intel SoC FPGA board and the Socket Client is running on Windows PC.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here we show the procedure to execute the socket client-server communication demonstration. In this setup procedure, the server program is running to Intel SoC FPGA board and the Socket Client is running on Windows PC.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Connect the DE10-Advanced board to Network via Ethernet port (J25).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Connect the DE10-Advanced board to Network via Ethernet port (J25).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Connect a USB cable to the USB-to-UART connector (J27) on the DE10-Advanced board and the host Windows PC.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Connect a USB cable to the USB-to-UART connector (J27) on the DE10-Advanced board and the host Windows PC.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Copy the executable file “socket_server” into the microSD card under the &amp;quot;/home/root&amp;quot; folder in Linux. (DE10-Advanced LXDE has pre-installed this code, so users can skip this copy action.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Copy the executable file “socket_server” into the microSD card under the &amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;/home/root&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;&amp;quot; folder in Linux. (DE10-Advanced LXDE has pre-installed this code, so users can skip this copy action.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Insert the LXDE booting micro SD card into the DE10-Advanced board. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Insert the LXDE booting micro SD card into the DE10-Advanced board. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Power on the DE10-Advanced board.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Power on the DE10-Advanced board.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*In Windows, launch the Putty to connect DE10-Advanced via the UART-to-USB port.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*In Windows, launch the Putty to connect DE10-Advanced via the UART-to-USB port.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*In the Putty, type &amp;quot;root&amp;quot; to login LXDE Linux.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*In the Putty, type &amp;quot;root&amp;quot; to login LXDE Linux.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Type &amp;quot;./socket_server 2020&amp;quot; to launch the server program with port number 2020 as shown in Figure 3-16. The port number can be any value between 2000 and 63500.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Type &amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''' &lt;/ins&gt;./socket_server 2020&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;&amp;quot; to launch the server program with port number 2020 as shown in Figure 3-16. The port number can be any value between 2000 and 63500.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:[[File:Start Socket Server.jpg|500px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;:[[File:Start Socket Server.jpg|500px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-16 Start Socket Server&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-16 Start Socket Server&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here is the procedure to start the socket client program and communicate with the client server program:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here is the procedure to start the socket client program and communicate with the client server program:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Make sure the SoC EDS is installed on your Windows and the Windows is connected to a network. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Make sure the SoC EDS is installed on your Windows and the Windows is connected to a network. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Copy the client program (windows/socket_client/socket_client.exe) in the example kit to your Windows. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Copy the client program (windows/socket_client/socket_client.exe) in the example kit to your Windows. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Launch the SoC EDS Command Shell. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Launch the SoC EDS Command Shell. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*In the command shell, change the current directory to the directory where socket_client.exe is located. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*In the command shell, change the current directory to the directory where socket_client.exe is located. &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*Then, type “./socket_client &amp;lt;ip address&amp;gt; 2020” to launch the client program to connect to the host server with port number 2020 as shown in Figure 3-17.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*Then, type “./socket_client &amp;lt;ip address&amp;gt; 2020” to launch the client program to connect to the host server with port number 2020 as shown in Figure 3-17.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:[[File:Start Client Program.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;:[[File:Start Client Program.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-17 Start Client Program&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-17 Start Client Program&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;*If connection is established successfully, a prompt message “Please enter the message.” will appear. Type “hello”, then an echo message “I got your message” will be sent from the client server and shown on terminal as shown in Figure 3-18. At the same time, the socket server program will dump the received message at which point it is terminated as shown in Figure 3-19.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;*If connection is established successfully, a prompt message “Please enter the message.” will appear. Type “hello”, then an echo message “I got your message” will be sent from the client server and shown on terminal as shown in Figure 3-18. At the same time, the socket server program will dump the received message at which point it is terminated as shown in Figure 3-19.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:[[File:Send Message in Client Program.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&lt;/ins&gt;:[[File:Send Message in Client Program.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::::Figure 3-18 Send Message in Client Program&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;::::::Figure 3-18 Send Message in Client Program&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bingxia</name></author>	</entry>

	<entry>
		<id>http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2435&amp;oldid=prev</id>
		<title>Bingxia at 07:46, 27 August 2018</title>
		<link rel="alternate" type="text/html" href="http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2435&amp;oldid=prev"/>
				<updated>2018-08-27T07:46:07Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 07:46, 27 August 2018&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:[[File:Server dumps received message.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:[[File:Server dumps received message.jpg|600px]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-19 Server dumps received message&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;:::::::Figure 3-19 Server dumps received message&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;'''[[DE10-Advance_Demonstration_Manual_revC#Chapter 3 Examples for HPS SoC|Back]]'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bingxia</name></author>	</entry>

	<entry>
		<id>http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2434&amp;oldid=prev</id>
		<title>Bingxia: Created page with &quot;This demonstration shows how two remote application processes communication via socket in client-server model. Based on this design example,developers can make their Linux Applic...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.terasic.com.tw/wiki/index.php?title=DE10_Advance_revC_demo:_Network_Socket&amp;diff=2434&amp;oldid=prev"/>
				<updated>2018-08-27T07:42:57Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;This demonstration shows how two remote application processes communication via socket in client-server model. Based on this design example,developers can make their Linux Applic...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This demonstration shows how two remote application processes communication via socket in client-server model. Based on this design example,developers can make their Linux Application Software, run on SoC FPGA boards and easily communicate with other hosts via a network socket.&lt;br /&gt;
&lt;br /&gt;
=Sockets=&lt;br /&gt;
Sockets are the fundamental technology for programming software to communicate on the transport layer of networks shown in Figure 3-11. A socket provides a bidirectional communication endpoint for sending and receiving data with another socket. Socket connections normally run between two different computers on a LAN, or across the Internet, but they can also be used for interprocess communication on a single computer.&lt;br /&gt;
:::[[File:Communicate on a network via a socket.jpg|300px]] &lt;br /&gt;
:::Figure 3-11 Communicate on a network via a socket&lt;br /&gt;
&lt;br /&gt;
=Client Server Model=&lt;br /&gt;
Most interprocess’s communication uses the client server model. These terms refer to the two processes which will be communicating with each other. One of the two processes, the client, connects to the other process, the server typically to makes a request for information. A good analogy is a person who makes a phone call to another person. &amp;lt;br/&amp;gt;&lt;br /&gt;
Notice that the client needs to know of the existence of and the address of the server, but the server does not need to know the address of (or even the existence of) the client prior to the connection being established.  &amp;lt;br/&amp;gt;&lt;br /&gt;
Notice also that once a connection is established, both sides can send and receive information. &amp;lt;br/&amp;gt;&lt;br /&gt;
The system calls for establishing a connection which is somewhat different for the client and the server, but both involve the basic construct of a socket. A socket is one end of an interprocess communication channel. The two processes each establish their own socket. Figure 3-12 shows the communication diagram between the client and server. &lt;br /&gt;
:::[[File:Client and Server communication.jpg|400px]]&lt;br /&gt;
::::Figure 3-12 Client and Server communication&lt;br /&gt;
The steps involved in establishing a socket on the client side are as follows:&lt;br /&gt;
*Create a socket with the socket() system call&lt;br /&gt;
*Connect the socket to the address of the server using the connect() system call&lt;br /&gt;
*Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.&lt;br /&gt;
&lt;br /&gt;
The steps involved in establishing a socket on the server side are as follows:&lt;br /&gt;
*Create a socket with the socket() system call&lt;br /&gt;
*Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.&lt;br /&gt;
*Listen for connections with the listen() system call&lt;br /&gt;
*Accept a connection with the accept() system call. This call typically blocks until a client connects with the server.&lt;br /&gt;
*Send and receive data. There are a number of ways to do this, but the simplest is to use the read() and write() system calls.&lt;br /&gt;
&lt;br /&gt;
=Example Code Explanation=&lt;br /&gt;
The example design contains two projects. One is socket server project, and one is socket client project. The SOCK_STREAM socket type is used in the design. The Linux Socket Library is used to provide socket functions, so remember to include the socket API header file – socket.h.&lt;br /&gt;
The major function of socket server program is to create a socket server based on the given port number and waiting a client to request to establish a connection. When a connection is established, the server is waiting for an incoming text message. When a message is received, it will show the receiver message on the console terminal, then send the message “I got your message” to the client socket, and then close the server program. Figure 3-13 shows the socket relative code statement. In the program, socket API is used to create a SOCK_STREAM socket, bind API is used to bind the socket to any incoming address and a specified port number. For connection, listen API is used to make the socket as a passive socket that is, as a socket that will be used to accept the incoming connection, and accept API is used to accept the incoming connection. The accept blocks until a client connects with the server. Data receiving and sending is implemented by the read and write API, and close is used to close the socket. &lt;br /&gt;
:::[[File:Socket Server Code.jpg|450px]]&lt;br /&gt;
::::::Figure 3-13 Socket Server Code&lt;br /&gt;
&lt;br /&gt;
The major function of the socket client program is to create a connection based on given hostname (or IP address) and host port. When a connection is established, it will show “Please enter the message: ” message on console terminal to ask users to input a message. After get user’s input message, the message is sent to a remote socket server via the socket. If the remote server socket received the message, it will return a message “I got the message”. The client program will show the received message on the console terminal and exit the program. Figure 3-14 shows the socket relative code statement. In the program, socket API is used to create a SOCK_STREAM socket, connect API is used to connect the remove socket sever based on the given hostname (or IP4v Address) and port number. Data receiving and sending is implemented by read and write API, and close is used to close the socket.&lt;br /&gt;
:::[[File:Socket Client Code.jpg|550px]]&lt;br /&gt;
:::::::Figure 3-14 Socket Client Code&lt;br /&gt;
&lt;br /&gt;
=Demonstration Source Code=&lt;br /&gt;
The source code of the design example is located in the Demonstration folder asshown in Figure 3-15. The Demonstration folder contains three platform subfolders: arm, linux and windows. The project under the arm folder is designed for SoC FPGA board. The project under linux folder is designed for Linux running on Linux PC. The project under windows folder is designed for SoC EDS Shell running on Windows PC. Each platform subfolder contains socket_client and socket_server project folders.&lt;br /&gt;
:::[[File:Source Code Folder Tree.jpg|150px]]&lt;br /&gt;
:::Figure 3-15 Source Code Folder Tree&lt;br /&gt;
&lt;br /&gt;
The socket_client project includes a Makefile and a source file main.c. For different platforms, the Makefile content is different, but the main.c content is the same. The socket_server project has the file project architecture.&lt;br /&gt;
&lt;br /&gt;
=Demonstration Setup=&lt;br /&gt;
Here we show the procedure to execute the socket client-server communication demonstration. In this setup procedure, the server program is running to Intel SoC FPGA board and the Socket Client is running on Windows PC.&lt;br /&gt;
*Connect the DE10-Advanced board to Network via Ethernet port (J25).&lt;br /&gt;
*Connect a USB cable to the USB-to-UART connector (J27) on the DE10-Advanced board and the host Windows PC.&lt;br /&gt;
*Copy the executable file “socket_server” into the microSD card under the &amp;quot;/home/root&amp;quot; folder in Linux. (DE10-Advanced LXDE has pre-installed this code, so users can skip this copy action.)&lt;br /&gt;
*Insert the LXDE booting micro SD card into the DE10-Advanced board. &lt;br /&gt;
*Power on the DE10-Advanced board.&lt;br /&gt;
*In Windows, launch the Putty to connect DE10-Advanced via the UART-to-USB port.&lt;br /&gt;
*In the Putty, type &amp;quot;root&amp;quot; to login LXDE Linux.&lt;br /&gt;
*Type &amp;quot;./socket_server 2020&amp;quot; to launch the server program with port number 2020 as shown in Figure 3-16. The port number can be any value between 2000 and 63500.&lt;br /&gt;
:[[File:Start Socket Server.jpg|500px]]&lt;br /&gt;
:::::::Figure 3-16 Start Socket Server&lt;br /&gt;
&lt;br /&gt;
Here is the procedure to start the socket client program and communicate with the client server program:&lt;br /&gt;
*Make sure the SoC EDS is installed on your Windows and the Windows is connected to a network. &lt;br /&gt;
*Copy the client program (windows/socket_client/socket_client.exe) in the example kit to your Windows. &lt;br /&gt;
*Launch the SoC EDS Command Shell. &lt;br /&gt;
*In the command shell, change the current directory to the directory where socket_client.exe is located. &lt;br /&gt;
*Then, type “./socket_client &amp;lt;ip address&amp;gt; 2020” to launch the client program to connect to the host server with port number 2020 as shown in Figure 3-17.&lt;br /&gt;
:[[File:Start Client Program.jpg|600px]]&lt;br /&gt;
:::::::Figure 3-17 Start Client Program&lt;br /&gt;
*If connection is established successfully, a prompt message “Please enter the message.” will appear. Type “hello”, then an echo message “I got your message” will be sent from the client server and shown on terminal as shown in Figure 3-18. At the same time, the socket server program will dump the received message at which point it is terminated as shown in Figure 3-19.&lt;br /&gt;
:[[File:Send Message in Client Program.jpg|600px]]&lt;br /&gt;
::::::Figure 3-18 Send Message in Client Program&lt;br /&gt;
&lt;br /&gt;
:[[File:Server dumps received message.jpg|600px]]&lt;br /&gt;
:::::::Figure 3-19 Server dumps received message&lt;/div&gt;</summary>
		<author><name>Bingxia</name></author>	</entry>

	</feed>