Commit 2b300c9a authored by 's avatar
Browse files

various fixes

git-svn-id: file:///home/svn/mapi/trunk@253 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 098305e4
......@@ -189,20 +189,47 @@ void *mapiipc_comm_thread(void *host) {
void mapiipc_remote_init(struct host *h)
//Initializes IPC for dmapi functions
{
struct hostent* host=gethostbyname(h->hostname);
struct timeval tv;
if ((h->sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
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);
}
// Construct name of dmapid's socket
remoteaddr.sin_family = AF_INET;
remoteaddr.sin_addr = *((struct in_addr *)gethostbyname(h->hostname)->h_addr);
remoteaddr.sin_addr = *((struct in_addr *)host->h_addr);
remoteaddr.sin_port = htons(h->port);
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);
}
}
void mapiipc_remote_close(struct host *h)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment