-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Define the compiler | ||
CC = gcc | ||
|
||
# Define the flags | ||
CFLAGS = -Wall -Wextra | ||
|
||
# Define the library flags | ||
LDFLAGS = -lws2_32 | ||
|
||
# Define the target executable | ||
TARGET = server | ||
|
||
# Define the source file | ||
SRC = webserver.c | ||
|
||
# Default target | ||
all: $(TARGET) | ||
|
||
# Build step | ||
$(TARGET): $(SRC) | ||
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LDFLAGS) | ||
|
||
# Run the server | ||
run: $(TARGET) | ||
./$(TARGET) | ||
|
||
# Clean step to remove the executable | ||
clean: | ||
rm -f $(TARGET) | ||
|
||
.PHONY: all run clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
|
||
#ifdef _WIN32 | ||
#include <winsock2.h> | ||
#include <ws2tcpip.h> | ||
#pragma comment(lib, "ws2_32.lib") | ||
#else | ||
#include <arpa/inet.h> | ||
#include <netinet/in.h> | ||
#include <sys/socket.h> | ||
#endif | ||
|
||
int main() { | ||
#ifdef _WIN32 | ||
WSADATA wsaData; | ||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { | ||
fprintf(stderr, "WSAStartup failed.\n"); | ||
return 1; | ||
} | ||
#endif | ||
|
||
printf("hello world"); | ||
|
||
#ifdef _WIN32 | ||
WSACleanup(); | ||
#endif | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Define the compiler | ||
CC = gcc | ||
|
||
# Define the flags | ||
CFLAGS = -Wall -Wextra | ||
|
||
# Define the library flags | ||
LDFLAGS = | ||
|
||
# Define the target executable | ||
TARGET = server | ||
|
||
# Define the source file | ||
SRC = webserver.c | ||
|
||
# Default target | ||
all: $(TARGET) | ||
|
||
# Build step | ||
$(TARGET): $(SRC) | ||
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LDFLAGS) | ||
|
||
# Run the server | ||
run: $(TARGET) | ||
./$(TARGET) | ||
|
||
# Clean step to remove the executable | ||
clean: | ||
rm -f $(TARGET) | ||
|
||
.PHONY: all run clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <netinet/in.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/socket.h> | ||
#include <unistd.h> | ||
|
||
// maximum application buffer | ||
#define APP_MAX_BUFFER 1024 | ||
#define PORT 8080 | ||
|
||
int main() { return 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
FROM golang:bookworm | ||
|
||
WORKDIR /app | ||
WORKDIR /go_server | ||
|
||
COPY ./src /app | ||
COPY . /go_server | ||
|
||
RUN go mod tidy | ||
|
||
RUN go build -o main | ||
|
||
CMD ["./main"] | ||
CMD ["./main"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.