Skip to content
Snippets Groups Projects
Commit 6273d75d authored by Elias Maurer's avatar Elias Maurer
Browse files

Delete client.c

parent 9fb3a750
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
// #include
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/aes.h> // For AES encryption
#include <wolfssl/wolfcrypt/rsa.h> // For RSA encryption
#include <wolfssl/ssl.h>
// #define SERVER_IP "134.103.106.107"
#define SERVER_IP "192.168.58.142"
#define SERVER_PORT 5111
#define BUFFER_SIZE 1024
int main() {
printf("XX")
int sock;
struct sockaddr_in server_addr;
char message[BUFFER_SIZE];
// Create socket
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
perror("Socket creation failed");
return -1;
}
// Define server address
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(SERVER_PORT);
server_addr.sin_addr.s_addr = inet_addr(SERVER_IP);
// Connect to the server
if (connect(sock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
perror("Connection failed");
close(sock);
return -1;
}
printf("Connected to %s:%d\n", SERVER_IP, SERVER_PORT);
// Loop for user input and sending messages
while (1) {
printf("-> ");
if (fgets(message, sizeof(message), stdin) != NULL) {
// Remove the newline character from the message
message[strcspn(message, "\n")] = 0;
// Send message to the server
if (send(sock, message, strlen(message), 0) < 0) {
perror("Send failed");
break;
}
}
}
// Close the socket
close(sock);
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment