Mutiplexed Displays Using Ethernet Socket Server.
Dependencies: SN74CBT3257 Binary_Switch OSL10564_74HC595
Revision 0:ddb5698aa782, committed 2017-10-30
- Comitter:
- deepikabhavnani
- Date:
- Mon Oct 30 16:59:55 2017 +0000
- Child:
- 1:74ecd404d5e5
- Commit message:
- TCP Sever example
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Mon Oct 30 16:59:55 2017 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Mon Oct 30 16:59:55 2017 +0000 @@ -0,0 +1,9 @@ +### Getting started with the TCPServer API ### + +TCPServer Example +TCP sever in this application accepts single telnet client connection and sends +buffer data. + +**Note:** The current example is limited to the ethernet interface on supported +devices. To use the example with a different interface, you will need to modify +main.cpp and replace the EthernetInterface class with the appropriate interface. \ No newline at end of file
Binary file img/uvision.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Oct 30 16:59:55 2017 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "TCPServer.h"
+#include "TCPSocket.h"
+
+int main()
+{
+ printf("TCP server example\n");
+
+ EthernetInterface eth;
+ eth.connect();
+
+ printf("The Server IP address is '%s'\n", eth.get_ip_address());
+
+ TCPServer srv;
+ TCPSocket client_sock;
+ SocketAddress client_addr;
+ char *buffer = new char[256];
+
+ /* Open the server on ethernet stack */
+ srv.open(ð);
+
+ /* Bind the HTTP port (TCP 80) to the server */
+ srv.bind(eth.get_ip_address(), 23);
+
+ /* Can handle x simultaneous connections */
+ srv.listen(1);
+
+ srv.accept(&client_sock, &client_addr);
+ printf("Accepted %s:%d\n", client_addr.get_ip_address(),
+ client_addr.get_port());
+ strcpy(buffer, "Hello \n\r");
+ client_sock.send(buffer, strlen(buffer));
+ client_sock.recv(buffer, 256);
+
+ client_sock.close();
+ delete[] buffer;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Oct 30 16:59:55 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#e62a1b9236b44e70ae3b0902dc538481c04d455b