wip change architecture
This commit is contained in:
36
mini_serv.c
36
mini_serv.c
@@ -1,5 +1,3 @@
|
||||
//#include <errno.h>
|
||||
//#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
@@ -8,35 +6,12 @@
|
||||
#include <stdio.h> //sprintf
|
||||
|
||||
|
||||
// accept
|
||||
// atoi
|
||||
// bind
|
||||
// bzero
|
||||
// calloc
|
||||
// close
|
||||
// exit
|
||||
// free
|
||||
// listen
|
||||
// malloc
|
||||
// memset
|
||||
// realloc
|
||||
// recv
|
||||
// select
|
||||
// send
|
||||
// socket
|
||||
// sprintf
|
||||
// strcat
|
||||
// strcpy
|
||||
// strlen
|
||||
// strstr
|
||||
// write
|
||||
|
||||
#define BUFSIZE 42000
|
||||
|
||||
typedef struct s_clients {
|
||||
typedef struct s_client {
|
||||
int id;
|
||||
char msg[BUFSIZE - 20];
|
||||
} t_clients;
|
||||
char msg[1024];
|
||||
} t_client;
|
||||
|
||||
void error(char *str) {
|
||||
write(2, str, strlen(str));
|
||||
@@ -80,8 +55,8 @@ int main(int ac, char **av) {
|
||||
int port;
|
||||
int max_fd;
|
||||
int ret;
|
||||
t_clients clients[FD_SETSIZE];
|
||||
t_clients client;
|
||||
t_client clients[FD_SETSIZE];
|
||||
t_client client;
|
||||
|
||||
char buf[BUFSIZE];
|
||||
char msg[BUFSIZE];
|
||||
@@ -103,6 +78,7 @@ int main(int ac, char **av) {
|
||||
FD_SET(server_fd, &fdset);
|
||||
max_fd = server_fd;
|
||||
client_id = 0;
|
||||
bzero(&clients, sizeof(clients));
|
||||
|
||||
while (1) {
|
||||
rdset = fdset;
|
||||
|
||||
Reference in New Issue
Block a user