Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cfinalrfg Oa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FERNANDEZ GASCA Ricardo
Cfinalrfg Oa
Commits
2d64e31f
Commit
2d64e31f
authored
2 years ago
by
FERNANDEZ GASCA Ricardo
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
2c5d30a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.h
+43
-0
43 additions, 0 deletions
server.h
with
43 additions
and
0 deletions
server.h
0 → 100644
+
43
−
0
View file @
2d64e31f
#ifndef SERVER_H
#define SERVER_H
#include
<poll.h>
/**
* The Server structure stores the file descriptors of the listening socket and
* the client socket. It can store up to 2 client socket to communicate with
* them
*/
struct
Server
{
struct
pollfd
fds
[
3
];
///< Array storing the listening socket + the client socket
int
nbClients
;
///< Current number of clients connected to the server
};
/**
* Given a server, accept new clients if there are less than 2
* currently connected.
*/
int
acceptNewClients
(
struct
Server
*
_server
);
/**
* Given a server and a socket, reads a Message from the socket and broadcast it
* to the other client. Return -1 if the message could not be read, -2 if the
* message could not be sent to the other client.
*
* If the message cannot be read, the socket descriptor of the sending client is
* set to -1.
*
* If the message cannot be sent, the socket descriptor of the would be
* receiving client is set to -1.
*/
int
receiveAndBroadcastMessage
(
struct
Server
*
_server
,
int
_sendingClientFd
);
/**
* Given a server, compact the array of descriptor if any client descriptor is
* set to -1.
*/
void
compactDescriptor
(
struct
Server
*
_server
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment