12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #ifndef SERVER_H
- #define SERVER_H
- #include <pthread.h>
- #include "Stream.h"
- typedef struct Server
- {
- int maxClients;
- short port;
- pthread_t* threads;
- int* clientSockets;
- char** clientUser;
- int connectSocket;
-
- int hAmount;
- int hIndex;
- ServerStreamFunction* handlers;
-
- char* directory;
- } Server;
- typedef struct ThreadData
- {
- int id;
- Server* server;
- } ThreadData;
- void serverInitDefaults(Server* s);
- int serverInit(Server* s, int maxClients, short port, char* directory);
- void serverRemove(Server* s);
- int serverSend(int clientSocket, Stream* out);
- void serverWaitForConnection(Server* s);
- void serverRegisterHandler(Server* s, ServerStreamFunction f);
- int serverSetUser(Server* s, int clientId, char* name);
- char* serverGetUser(Server* s, int clientId);
- void serverFreeUser(Server* s, int clientId);
- #endif
|