Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
2b300c9a
Commit
2b300c9a
authored
Nov 10, 2005
by
Browse files
various fixes
git-svn-id:
file:///home/svn/mapi/trunk@253
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
098305e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
mapiipc.c
View file @
2b300c9a
...
@@ -189,20 +189,47 @@ void *mapiipc_comm_thread(void *host) {
...
@@ -189,20 +189,47 @@ void *mapiipc_comm_thread(void *host) {
void
mapiipc_remote_init
(
struct
host
*
h
)
void
mapiipc_remote_init
(
struct
host
*
h
)
//Initializes IPC for dmapi functions
//Initializes IPC for dmapi functions
{
{
struct
hostent
*
host
=
gethostbyname
(
h
->
hostname
);
struct
timeval
tv
;
if
((
h
->
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
-
1
)
{
if
((
h
->
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
-
1
)
{
ERROR_CMD
(
printf
(
"socket: %s [%s:%d]
\n
"
,
strerror
(
errno
),
__FILE__
,
__LINE__
));
ERROR_CMD
(
printf
(
"socket: %s [%s:%d]
\n
"
,
strerror
(
errno
),
__FILE__
,
__LINE__
));
exit
(
-
1
);
}
tv
.
tv_sec
=
20
;
//timeout 20 sec for recv
tv
.
tv_usec
=
0
;
if
(
setsockopt
(
h
->
sockfd
,
SOL_SOCKET
,
SO_RCVTIMEO
,
&
tv
,
sizeof
(
struct
timeval
))
==
-
1
)
{
close
(
h
->
sockfd
);
printf
(
"Unexpected error on setsockopt()"
);
exit
(
-
1
);
}
tv
.
tv_sec
=
10
;
//timeout 10 sec for send
tv
.
tv_usec
=
0
;
if
(
setsockopt
(
h
->
sockfd
,
SOL_SOCKET
,
SO_SNDTIMEO
,
&
tv
,
sizeof
(
struct
timeval
))
==
-
1
)
{
close
(
h
->
sockfd
);
printf
(
"Unexpected error on setsockopt()"
);
exit
(
-
1
);
}
if
(
host
==
NULL
)
{
printf
(
"Could not determine address for %s
\n
"
,
h
->
hostname
);
exit
(
1
);
exit
(
1
);
}
}
// Construct name of dmapid's socket
// Construct name of dmapid's socket
remoteaddr
.
sin_family
=
AF_INET
;
remoteaddr
.
sin_family
=
AF_INET
;
remoteaddr
.
sin_addr
=
*
((
struct
in_addr
*
)
get
host
byname
(
h
->
hostname
)
->
h_addr
);
remoteaddr
.
sin_addr
=
*
((
struct
in_addr
*
)
host
->
h_addr
);
remoteaddr
.
sin_port
=
htons
(
h
->
port
);
remoteaddr
.
sin_port
=
htons
(
h
->
port
);
if
(
connect
(
h
->
sockfd
,
(
struct
sockaddr
*
)
&
remoteaddr
,
sizeof
(
remoteaddr
))
<
0
)
{
if
(
connect
(
h
->
sockfd
,
(
struct
sockaddr
*
)
&
remoteaddr
,
sizeof
(
remoteaddr
))
<
0
)
{
ERROR_CMD
(
printf
(
"connect: %s [%s:%d]
\n
"
,
strerror
(
errno
),
__FILE__
,
__LINE__
));
ERROR_CMD
(
printf
(
"connect
failed
: %s [%s:%d]
\n
"
,
strerror
(
errno
),
__FILE__
,
__LINE__
));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
void
mapiipc_remote_close
(
struct
host
*
h
)
void
mapiipc_remote_close
(
struct
host
*
h
)
...
...
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