Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Seminar-HFO
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
Seminar-HFO
Commits
0aaeed5f
Commit
0aaeed5f
authored
Jun 08, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added timeout for connection to server.
parent
0f0a2ce5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
hfo/hfo.py
hfo/hfo.py
+6
-1
src/HFO.cpp
src/HFO.cpp
+8
-3
No files found.
hfo/hfo.py
View file @
0aaeed5f
...
@@ -43,14 +43,19 @@ class HFOEnvironment(object):
...
@@ -43,14 +43,19 @@ class HFOEnvironment(object):
'''Connect to the server that controls the agent on the specified port. '''
'''Connect to the server that controls the agent on the specified port. '''
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
print
'[Agent Client] Connecting to Agent Server on port'
,
server_port
print
'[Agent Client] Connecting to Agent Server on port'
,
server_port
while
True
:
retry
=
10
while
retry
>
0
:
try
:
try
:
self
.
socket
.
connect
((
'localhost'
,
server_port
))
self
.
socket
.
connect
((
'localhost'
,
server_port
))
except
:
except
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
retry
-=
1
continue
continue
else
:
else
:
break
break
if
retry
<=
0
:
print
'[Agent Client] ERROR Unable to communicate with server'
exit
(
1
)
print
'[Agent Client] Connected'
print
'[Agent Client] Connected'
self
.
handshakeAgentServer
(
feature_set
)
self
.
handshakeAgentServer
(
feature_set
)
# Get the initial state
# Get the initial state
...
...
src/HFO.cpp
View file @
0aaeed5f
...
@@ -24,8 +24,8 @@ HFOEnvironment::~HFOEnvironment() {
...
@@ -24,8 +24,8 @@ HFOEnvironment::~HFOEnvironment() {
close
(
sockfd
);
close
(
sockfd
);
}
}
void
HFOEnvironment
::
connectToAgentServer
(
int
server_port
,
void
HFOEnvironment
::
connectToAgentServer
(
int
server_port
,
feature_set_t
feature_set
)
{
feature_set_t
feature_set
)
{
std
::
cout
<<
"[Agent Client] Connecting to Agent Server on port "
std
::
cout
<<
"[Agent Client] Connecting to Agent Server on port "
<<
server_port
<<
std
::
endl
;
<<
server_port
<<
std
::
endl
;
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
...
@@ -45,9 +45,14 @@ HFOEnvironment::~HFOEnvironment() {
...
@@ -45,9 +45,14 @@ HFOEnvironment::~HFOEnvironment() {
server
->
h_length
);
server
->
h_length
);
serv_addr
.
sin_port
=
htons
(
server_port
);
serv_addr
.
sin_port
=
htons
(
server_port
);
int
status
=
-
1
;
int
status
=
-
1
;
while
(
status
<
0
)
{
int
retry
=
10
;
while
(
status
<
0
&&
retry
>
0
)
{
status
=
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
status
=
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
sleep
(
1
);
sleep
(
1
);
retry
--
;
}
if
(
status
<
0
)
{
error
(
"[Agent Client] ERROR Unable to communicate with server"
);
}
}
std
::
cout
<<
"[Agent Client] Connected"
<<
std
::
endl
;
std
::
cout
<<
"[Agent Client] Connected"
<<
std
::
endl
;
handshakeAgentServer
(
feature_set
);
handshakeAgentServer
(
feature_set
);
...
...
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