-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some bugs + correct proto DL / UL + fix send ID impossible
- Loading branch information
HorlogeSkynet
committed
Nov 5, 2015
1 parent
bd5065f
commit 9251e3f
Showing
13 changed files
with
167 additions
and
158 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
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
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
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
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
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,56 @@ | ||
#include <server.h> | ||
|
||
void broadcast(int sender, const char *msg) | ||
{ | ||
for(short int _i = 0; _i < MAX_CLIENTS; _i++) | ||
{ | ||
if(_i != sender) | ||
{ | ||
send(g_clients[_i].sock, msg, BUFFER, false); | ||
} | ||
} | ||
} | ||
|
||
void close_all_connections() | ||
{ | ||
printf("\n[WIFSS] Closing all connections..."); | ||
|
||
char _buffer[BUFFER] = ""; | ||
sprintf(_buffer, "%s", DISCONNECT); | ||
|
||
for(short int _i = 0; _i < MAX_CLIENTS; _i++) | ||
{ | ||
if(g_clients[_i].status == TAKEN) | ||
{ | ||
send(g_clients[_i].sock, _buffer, BUFFER, false); | ||
} | ||
printf("."); | ||
} | ||
printf(" done.\n"); | ||
} | ||
|
||
void closeServer(int listen_socket) | ||
{ | ||
close_all_connections(); | ||
|
||
if(close(listen_socket) == -1) | ||
{ | ||
printf("\n\033[35m[WIFSS] Socket of server couldn't be successfully closed.\033[0m\n"); | ||
} | ||
else | ||
{ | ||
printf("\n\033[32m[WIFSS] Socket of server successfully closed.\033[0m\n"); | ||
} | ||
|
||
for(short int _i = 0; _i < MAX_CLIENTS; _i++) | ||
{ | ||
pthread_cancel(threads[_i]); | ||
} | ||
|
||
printf("[WIFSS] Server stopped.\n"); | ||
for(short int _k = 0; _k < 60; _k++) | ||
{ | ||
printf("="); | ||
} | ||
printf("\n\n"); | ||
} |
Oops, something went wrong.