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
147c0951
Commit
147c0951
authored
Sep 29, 2016
by
Deomid Ryabkov
Committed by
Cesanta Bot
Sep 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report errors in the netcat example
PUBLISHED_FROM=f43dc48512ff13028a57571b537c41d9658034b5
parent
fecb11f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
nc.c
examples/netcat/nc.c
+14
-6
No files found.
examples/netcat/nc.c
View file @
147c0951
...
...
@@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
int
i
,
is_listening
=
0
;
const
char
*
address
=
NULL
;
struct
mg_connection
*
c
;
// struct mg_bind_opts = {}
;
const
char
*
err
=
NULL
;
mg_mgr_init
(
&
mgr
,
NULL
);
...
...
@@ -133,13 +133,21 @@ int main(int argc, char *argv[]) {
signal
(
SIGPIPE
,
SIG_IGN
);
if
(
is_listening
)
{
if
((
c
=
mg_bind
(
&
mgr
,
address
,
ev_handler
))
==
NULL
)
{
fprintf
(
stderr
,
"mg_bind(%s) failed
\n
"
,
address
);
struct
mg_bind_opts
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
error_string
=
&
err
;
if
((
c
=
mg_bind_opt
(
&
mgr
,
address
,
ev_handler
,
opts
))
==
NULL
)
{
fprintf
(
stderr
,
"mg_bind(%s) failed: %s
\n
"
,
address
,
err
);
exit
(
EXIT_FAILURE
);
}
}
else
{
struct
mg_connect_opts
opts
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
opts
.
error_string
=
&
err
;
if
((
c
=
mg_connect_opt
(
&
mgr
,
address
,
ev_handler
,
opts
))
==
NULL
)
{
fprintf
(
stderr
,
"mg_connect(%s) failed: %s
\n
"
,
address
,
err
);
exit
(
EXIT_FAILURE
);
}
}
else
if
((
c
=
mg_connect
(
&
mgr
,
address
,
ev_handler
))
==
NULL
)
{
fprintf
(
stderr
,
"mg_connect(%s) failed
\n
"
,
address
);
exit
(
EXIT_FAILURE
);
}
if
(
s_is_websocket
)
{
mg_set_protocol_http_websocket
(
c
);
...
...
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