aboutsummaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'server.c')
-rw-r--r--server.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/server.c b/server.c
index dbdaa67..fdc8724 100644
--- a/server.c
+++ b/server.c
@@ -13,6 +13,12 @@
typedef enum { GET = 0, POST = 1, UNKNOWN = -1 } HTTP_METHODS;
+static void usage(const char *progname)
+{
+ fprintf(stderr, "Usage: %s <port>\n", progname);
+ exit(EXIT_FAILURE);
+}
+
int shsd_sendfile(int in_fd, FILE *ou_fd)
{
struct stat s;
@@ -81,6 +87,9 @@ int handle_client(int client_fd, char *buf)
int main(int argc, char **argv)
{
+ if (argc < 2) {
+ usage(argv[0]);
+ }
struct addrinfo hints, *res;
struct sockaddr_storage their_addr;
socklen_t addr_size;