3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #ifndef __IPCSocket_H__
32 #define __IPCSocket_H__
34 /*==================================================================================================
36 ==================================================================================================*/
37 #include <sys/types.h>
41 #include "MsgCppTypes.h"
44 /*==================================================================================================
46 ==================================================================================================*/
47 #define MSG_MAX_IPC_SIZE 50000 // 50 * 1000 = sizeof(msg common info) * max message count
48 #define MAX_NUM_IPC_CLIENT 10
50 #define MSG_SOCKET_PATH "/tmp/.msgfw_socket"
52 #define CUSTOM_SOCKET_ERROR -1
53 #define CUSTOM_SOCKET_BACKLOG 10
56 /*==================================================================================================
58 ==================================================================================================*/
61 CLOSE_CONNECTION_BY_SIGNAL = 0,
62 CLOSE_CONNECTION_BY_USER = -17,
66 /*==================================================================================================
68 ==================================================================================================*/
69 class MsgIpcClientSocket
73 // ~MsgIpcClientSocket();
75 int maxFd() { return (maxfd+1); }
76 fd_set fdSet() { return fds; }
77 int fd() { return sockfd; }
79 MSG_ERROR_T connect(const char *path);
81 /* write msg to ipc server */
82 int write(const char* buf, int len);
83 /* read msg from ipc server */
84 int read(char** buf, int* len);
86 int getRemoteFd() {return remotefd; }
88 int readn(char *buf, int len );
89 int writen (const char *buf, int len);
91 int sockfd, remotefd, maxfd;
96 class MsgIpcServerSocket
100 ~MsgIpcServerSocket() { mapFds.clear(); }
101 int maxFd() { return (maxfd+1); }
102 fd_set fdSet() { return fds; }
103 int fd() { return sockfd; }
105 MSG_ERROR_T open(const char *path);
106 MSG_ERROR_T accept();
109 /* read msg from client of fd */
110 int read(int fd, char** buf, int* len );
111 /* write msg to ipc client */
112 int write(int fd, const char* buf, int len);
114 void setSockfd(int fd) { sockfd = fd; }
117 int readn(int fd, char *buf, int len );
118 int writen (int fd, const char *buf, int len);
120 /* server socket fd */
123 /* information about IPC clients, it is used for select() */
126 std::map<int, int> mapFds;
129 #endif //__IPCSocket_H__