Echo Server

An example of socket programming using Donatien's network stack (http://mbed.org/cookbook/Networking-Stack-Releases).

This program sets up a server listening on TCP and UDP port 7 for incoming connections.  Any data received will be sent directly back to the client as per RFC862.

The code is heavily commented so will hopefully help some other people to get started with the socket API.

http://mbed.org/users/darran/programs/EchoServer

Once the program is up and running on your mbed, you can test it by using a simple telnet client to connect to port 7:

telnet <mbed_ip> 7

Then any characters that you send should be echoed back to you.  If local echo is on, you will see each character duplicated.

You can also try pushing the mbed harder by using something like ttcp.You can download a Windows binary for this from PCAUSA or install on a Mac using Darwin Ports.

>pcattcp -t -p7 -v -n 100 -l 512 <mbed_ip>
PCAUSA Test TCP Utility V2.01.01.11
Started TCP Transmit Test 0...
TCP Transmit Test
Transmit    : TCP -> 192.168.1.158:7
Buffer Size : 512; Alignment: 16384/0
TCP_NODELAY : DISABLED (0)
Connect     : Connected to 192.168.1.158:7
Send Mode   : Send Pattern; Number of Buffers: 100
Statistics  : TCP -> 192.168.1.158:7
51200 bytes in 16.69 real seconds = 3.00 KB/sec +++
numCalls: 100; msec/call: 170.87; calls/sec: 5.99

To do:

Figure out why UDP doesn't seem to be working.  I do not seem to get any UDP events called at all.


1 comment

22 Oct 2010

I dont get it working, I imported the the NetServicesSource from http://mbed.org/users/donatien/programs/NetServicesSource/5zh9t, but there are many compiler-faults. Am I missing something?

You need to log in to post a comment