Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
88a224d8
Commit
88a224d8
authored
Jul 05, 2010
by
valenok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed example. some more comments added
parent
5425b94f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
chat.c
examples/chat.c
+13
-8
mongoose.c
mongoose.c
+1
-1
mongoose.h
mongoose.h
+1
-0
No files found.
examples/chat.c
View file @
88a224d8
...
...
@@ -350,19 +350,24 @@ static enum mg_error_t process_request(struct mg_connection *conn,
}
int
main
(
void
)
{
struct
mg_context
*
ctx
;
struct
mg_context
*
ctx
;
struct
mg_config
config
;
// Initialize random number generator. It will be used later on for
// the session identifier creation.
srand
((
unsigned
)
time
(
0
));
// Start and setup Mongoose
ctx
=
mg_start
();
mg_set_option
(
ctx
,
"root"
,
web_root
);
mg_set_option
(
ctx
,
"ssl_cert"
,
ssl_certificate
);
// Must be set before ports
mg_set_option
(
ctx
,
"ports"
,
http_ports
);
mg_set_option
(
ctx
,
"dir_list"
,
"no"
);
// Disable directory listing
mg_set_callback
(
ctx
,
MG_EVENT_NEW_REQUEST
,
&
process_request
);
// Setup and start Mongoose
memset
(
&
config
,
0
,
sizeof
(
config
));
config
.
document_root
=
web_root
;
config
.
listening_ports
=
http_ports
;
config
.
ssl_certificate
=
ssl_certificate
;
config
.
index_files
=
"index.html"
;
config
.
new_request_handler
=
&
process_request
;
config
.
auth_domain
=
""
;
config
.
num_threads
=
"5"
;
ctx
=
mg_start
(
&
config
);
assert
(
ctx
!=
NULL
);
// Wait until enter is pressed, then exit
printf
(
"Chat server started on ports %s, press enter to quit.
\n
"
,
http_ports
);
...
...
mongoose.c
View file @
88a224d8
...
...
@@ -4300,7 +4300,7 @@ mg_start(struct mg_config *config)
/*
* NOTE(lsm): order is important here. SSL certificates must
* be initialized before listening ports.
* be initialized before listening ports.
UID must be set last.
*/
if
(
set_ssl_option
(
ctx
)
==
MG_ERROR
||
set_ports_option
(
ctx
)
==
MG_ERROR
||
...
...
mongoose.h
View file @
88a224d8
...
...
@@ -121,6 +121,7 @@ struct mg_config {
* This must be the first function called by the application.
* It creates a serving thread, and returns a context structure that
* can be used to stop the server.
* After calling mg_start(), configuration data must not be changed.
*/
struct
mg_context
*
mg_start
(
struct
mg_config
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment