Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CyaSSL EthernetInterface-FRDM mbed-rtos mbed
Fork of CyaSSL-EchoClient by
Diff: main.cpp
- Revision:
- 3:0cab91ba32c1
- Parent:
- 2:dc88e0c4270e
--- 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))
