Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30023-2019-project-1
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
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
Xun Zhang
comp30023-2019-project-1
Commits
059c836e
Commit
059c836e
authored
Apr 29, 2019
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
restart error print test
parent
5139f9e3
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.c
+11
-6
11 additions, 6 deletions
server.c
with
11 additions
and
6 deletions
server.c
+
11
−
6
View file @
059c836e
...
...
@@ -201,11 +201,13 @@ static bool handle_http_request(int sockfd) {
}
// players setting and detecting
if
(
p1_sockfd
<
0
&&
sockfd
!=
p2_sockfd
)
if
(
p1_sockfd
<
0
&&
sockfd
!=
p2_sockfd
)
{
printf
(
"p1 sockfd is set to %d.
\r\n
"
,
sockfd
);
p1_sockfd
=
sockfd
;
else
if
(
p2_sockfd
<
0
&&
sockfd
!=
p1_sockfd
)
}
else
if
(
p2_sockfd
<
0
&&
sockfd
!=
p1_sockfd
)
{
printf
(
"p2 sockfd is set to %d.
\r\n
"
,
sockfd
);
p2_sockfd
=
sockfd
;
else
if
(
sockfd
!=
p1_sockfd
&&
sockfd
!=
p2_sockfd
)
{
}
else
if
(
sockfd
!=
p1_sockfd
&&
sockfd
!=
p2_sockfd
)
{
perror
(
"more than 2 players"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -253,11 +255,13 @@ static bool handle_http_request(int sockfd) {
}
else
if
(
*
curr
==
'?'
)
{
if
(
method
==
GET
)
{
// flag ready for players
if
(
sockfd
==
p1_sockfd
)
if
(
sockfd
==
p1_sockfd
)
{
printf
(
"p1 is ready.
\r\n
"
);
p1_is_ready
=
true
;
else
if
(
sockfd
==
p2_sockfd
)
}
else
if
(
sockfd
==
p2_sockfd
)
{
printf
(
"p2 is ready.
\r\n
"
);
p2_is_ready
=
true
;
else
{
}
else
{
perror
(
"more than 2 players"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -416,6 +420,7 @@ bool keyword_check(int sockfd, char* keyword) {
}
void
player_init
()
{
printf
(
"Player init.
\r\n
"
);
p1_is_ready
=
p2_is_ready
=
false
;
p1_sockfd
=
p2_sockfd
=
-
1
;
p1_guess_len
=
p2_guess_len
=
0
;
...
...
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