wolf SSL / Mbed 2 deprecated SimpleClient-SSL-FRDM

Dependencies:   CyaSSL EthernetInterface-FRDM mbed-rtos mbed

Fork of CyaSSL-EchoClient by wolf SSL

Files at this revision

API Documentation at this revision

Comitter:
wolfSSL
Date:
Sat Feb 07 18:38:56 2015 +0000
Parent:
2:dc88e0c4270e
Commit message:
getline for server ip address

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Feb 07 11:39:58 2015 +0000
+++ b/main.cpp	Sat Feb 07 18:38:56 2015 +0000
@@ -32,6 +32,16 @@
     return n ;
 }
 
+void getline(char *line, int size) {
+    for(int i=0; i<size; i++) {
+        if((line[i] = getchar()) == '\r') {
+            line[i] = '\0' ;
+            putchar('\n') ;
+            break ;
+        } else putchar(line[i]) ;
+    }
+}
+
 EthernetInterface eth;
 
 void net_main(void const *av)
@@ -52,8 +62,7 @@
 
     socket.set_blocking(false, 300) ;
     printf("Server IP: ") ;
-    scanf("%s", server_ip) ; 
-    puts(server_ip) ;
+    getline(server_ip, sizeof(server_ip)) ; 
     while (socket.connect(server_ip, PORT) < 0) {
         printf("Unable to connect to (%s) on port (%d)\n", server_ip, PORT);
         wait(1);
@@ -70,8 +79,8 @@
         err_sys("SSL Connection Error");
     }
     printf("SSL Connected\n") ;
-
-    char msg[] = "GET / HTTP/1.0\r\nConnection:close\r\n\r\n" ;
+ 
+    char msg[] = "GET /index.html HTTP/1.0\r\nConnection:close\r\n\r\n" ;
     printf("Client Request: \n%s\n",msg) ;
     if (CyaSSL_write(ssl, 
         /* socket.send(*/ msg, sizeof(msg)-1) != (sizeof(msg)-1))