The beginning of IoT Server! Making TCP/IP Server

 

Intro

The world now is the IoT era. What is the most important thing on IoT? Internet! In other words, it is the connection between devices. What are the methods for connecting between devices then? Looking at the big picture, it can be divided into wired communication and wireless communication, and a large part of wired communication is TCP/IP. In this article, I would like to introduce how to make TCP/IP Server, one of the methods for connecting between devices, easy and simple.

STEP1. Making a simple TCP/IP Loopback Server

 

IoT tcp application by using BSD socket

Simple Arduino Webserver with Ethernet shield

There are many projects that implement TCP/IP Server using WIZwiki W7500 or Arduino inWIZnetmuseum.

In this article, I would like to talk about creating TCP/IP Loopback Server with Loopback function (Returning data received from the client as it is) using W5100S-EVB.

 

STEP 2. Materials

 2-1. W5100S-EVB (Detail and Buy)

 2-2. LAN Cable

 2-3. Eclipse IDE

 2-4. Hercules (Serial Terminal, Hercules Download)

 2-5. ST Flash loader demonstrator (ST Flash loader Download)

 

STEP 3. Make!

3-1. W5100S-EVB Source Download (W5100S-EVB Source Download)

3-1. W5100S-EVB Source Download

 

 3-2. Eclipse IDE Preferences

 3-2. Setting up the Eclipse IDE

-Eclipse IDE (Eclipse IDE Download)

-Windows Build Tools (Windows Build Tools Download)

-Java JRE (Java JRE Download)

-GCC Compiler (GCC Compiler Download)

 

 3-3. Creation of W5100S-EVB Project (by using Eclipse)

After building up the Eclipse Project, import and compile the project. Please see the link below for more details.

Creation of W5100S-EVB Project: Make New W5100S-EVB Projects using Eclipse

 

3-4. Hardware connection

EVB board

Ps. You have to press the Boot button while W5100S-EVB power is off to upload the firmware by using Flash Loader.

 

STEP 4. Code

You can easily make a TCP loopback server by using loopback_tcps(), which is declared in the Library’s Application -> loopback.h.

 

Code

-The loopback function which is declared in loopback.h-

The parameters for loopback_tcps() are sn: Socket Number, buf: Buffer, and port: Port number.

The main part of the operation is the SOCK_ESTABLISHED within loopback_tcps(). The data received from recv() is stored in buf, and the data stored in buf is sent back to the client by using send().

 

loopback Code

 

STEP 5. Let’s Run!

5-1. Connect Hercules to the W5100S-EVB with Serial Terminal to observe the operation.

5-2. Use Hercules to connect to the TCP loopback server implemented in W5100S-EVB with TCP Client.

5-3. After connection, check the operation of TCP loopback server by sending data to W5100S-EVB.

 

http://http://wiznet.ipdisk.co.kr:80/publist/HDD1/Distributors/TCC/W5100S-EVB_TCP_loopback.avi 

In conclusion

We have learned how to create a simple TCP/IP loopback Server by using W5100S-EVB so far. A TCP loopback Client or a UDP loopback Server can be easily implemented as well as creating a TCP/IP loopback Server. And if you apply this, you can easily implement a simple IoT Server Project.

 

Curator: Matthew

Email: Matthew@wiznet.io