Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
5a737f9c
Commit
5a737f9c
authored
May 22, 2007
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restart if bind error
parent
0bdae90d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
34 deletions
+38
-34
opc/exe/opc_server/src/opc_server.cpp
opc/exe/opc_server/src/opc_server.cpp
+38
-34
No files found.
opc/exe/opc_server/src/opc_server.cpp
View file @
5a737f9c
/*
* Proview $Id: opc_server.cpp,v 1.1
5 2007-04-30 07:29:2
7 claes Exp $
* Proview $Id: opc_server.cpp,v 1.1
6 2007-05-22 08:21:1
7 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -164,6 +164,7 @@ int main()
qcom_sQid
qini
;
qcom_sQattr
qAttr
;
qcom_sQid
qid
=
qcom_cNQid
;
int
restarts
=
10
;
sts
=
gdh_Init
(
"opc_server"
);
if
(
EVEN
(
sts
))
{
...
...
@@ -236,42 +237,45 @@ int main()
errh_SetStatus
(
PWR__SRUN
);
soap_init
(
&
soap
);
m
=
soap_bind
(
&
soap
,
NULL
,
18083
,
100
);
if
(
m
<
0
)
soap_print_fault
(
&
soap
,
stderr
);
else
{
fprintf
(
stderr
,
"Socket connection successfull: master socket = %d
\n
"
,
m
);
for
(
int
i
=
1
;;
i
++
)
{
s
=
soap_accept
(
&
soap
);
if
(
s
<
0
)
{
soap_print_fault
(
&
soap
,
stderr
);
break
;
}
fprintf
(
stderr
,
"%d: request from IP=%lu.%lu.%lu.%lu socket=%d
\n
"
,
i
,
(
soap
.
ip
>>
24
)
&
0xFF
,(
soap
.
ip
>>
16
)
&
0xFF
,(
soap
.
ip
>>
8
)
&
0xFF
,
soap
.
ip
&
0xFF
,
s
);
opcsrv
->
m_config
->
RequestCnt
++
;
opcsrv
->
m_client
=
opcsrv
->
find_client
(
soap
.
ip
);
if
(
!
opcsrv
->
m_client
)
opcsrv
->
m_client
=
opcsrv
->
new_client
(
soap
.
ip
);
if
(
!
opcsrv
->
m_client
->
m_multi_threaded
)
{
if
(
soap_serve
(
&
soap
)
!=
SOAP_OK
)
// Process RPC request
for
(
int
k
=
0
;
k
<
restarts
+
1
;
k
++
)
{
m
=
soap_bind
(
&
soap
,
NULL
,
18083
,
100
);
if
(
m
<
0
)
soap_print_fault
(
&
soap
,
stderr
);
else
{
fprintf
(
stderr
,
"Socket connection successfull: master socket = %d
\n
"
,
m
);
for
(
int
i
=
1
;;
i
++
)
{
s
=
soap_accept
(
&
soap
);
if
(
s
<
0
)
{
soap_print_fault
(
&
soap
,
stderr
);
soap_destroy
(
&
soap
);
// Clean up class instances
soap_end
(
&
soap
);
// Clean up everything and close socket
}
else
{
// Create a thread for every request
struct
soap
*
tsoap
;
pthread_t
tid
;
tsoap
=
soap_copy
(
&
soap
);
if
(
!
tsoap
)
break
;
pthread_create
(
&
tid
,
NULL
,
opcsrv_process_request
,
(
void
*
)
tsoap
);
}
fprintf
(
stderr
,
"%d: request from IP=%lu.%lu.%lu.%lu socket=%d
\n
"
,
i
,
(
soap
.
ip
>>
24
)
&
0xFF
,(
soap
.
ip
>>
16
)
&
0xFF
,(
soap
.
ip
>>
8
)
&
0xFF
,
soap
.
ip
&
0xFF
,
s
);
opcsrv
->
m_config
->
RequestCnt
++
;
opcsrv
->
m_client
=
opcsrv
->
find_client
(
soap
.
ip
);
if
(
!
opcsrv
->
m_client
)
opcsrv
->
m_client
=
opcsrv
->
new_client
(
soap
.
ip
);
if
(
!
opcsrv
->
m_client
->
m_multi_threaded
)
{
if
(
soap_serve
(
&
soap
)
!=
SOAP_OK
)
// Process RPC request
soap_print_fault
(
&
soap
,
stderr
);
soap_destroy
(
&
soap
);
// Clean up class instances
soap_end
(
&
soap
);
// Clean up everything and close socket
}
else
{
// Create a thread for every request
struct
soap
*
tsoap
;
pthread_t
tid
;
tsoap
=
soap_copy
(
&
soap
);
if
(
!
tsoap
)
break
;
pthread_create
(
&
tid
,
NULL
,
opcsrv_process_request
,
(
void
*
)
tsoap
);
}
}
}
}
...
...
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