diff options
author | Dr. Stephen Henson <steve@openssl.org> | 1999-09-20 22:09:17 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 1999-09-20 22:09:17 +0000 |
commit | 06f4536a616c228a222beca36e15eabb430d3a5f (patch) | |
tree | 5a5fcc5bbcac84e02a5844188730117de266bf35 /apps/s_server.c | |
parent | bf1966354a62c5c6efbc47c3b4159703d8b546f9 (diff) | |
download | openssl-06f4536a616c228a222beca36e15eabb430d3a5f.tar.gz |
Fix to make s_client and s_server work under Windows. A bit of a hack but
an improvement on not working at all.
Diffstat (limited to 'apps/s_server.c')
-rw-r--r-- | apps/s_server.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/apps/s_server.c b/apps/s_server.c index 144dfa662f..3ed008c3cf 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -85,6 +85,10 @@ typedef unsigned int u_int; #include <openssl/ssl.h> #include "s_apps.h" +#ifdef WINDOWS +#include <conio.h> +#endif + #if (defined(VMS) && __VMS_VER < 70000000) /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ #undef FIONBIO @@ -748,6 +752,9 @@ static int sv_body(char *hostname, int s, unsigned char *context) unsigned long l; SSL *con=NULL; BIO *sbio; +#ifdef WINDOWS + struct timeval tv; +#endif if ((buf=Malloc(bufsize)) == NULL) { @@ -807,9 +814,22 @@ static int sv_body(char *hostname, int s, unsigned char *context) * the compiler: if you do have a cast then you can either * go for (int *) or (void *). */ - i=select(width,(void *)&readfds,NULL,NULL,NULL); - if (i <= 0) continue; - if (FD_ISSET(fileno(stdin),&readfds)) +#ifdef WINDOWS + /* Under Windows we can't select on stdin: only + * on sockets. As a workaround we timeout the select every + * second and check for any keypress. In a proper Windows + * application we wouldn't do this because it is inefficient. + */ + tv.tv_sec = 1; + tv.tv_usec = 0; + i=select(width,(void *)&readfds,NULL,NULL,&tv); + if((i < 0) || (!i && !_kbhit() ) )continue; + if(_kbhit()) +#else + i=select(width,(void *)&readfds,NULL,NULL,NULL); + if (i <= 0) continue; + if (FD_ISSET(fileno(stdin),&readfds)) +#endif { if (s_crlf) { |