4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHyun Kim <jh8212.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #if !defined(_CSOCK_CLASS_H_)
26 #define _CSOCK_CLASS_H_
27 #include <cipc_worker.h>
28 class csock : public cmutex
47 csock(int handle, int mode = 0x15);
48 csock(char *name, int mode, int port, int server = 0);
51 bool connect_to_server(void);
52 bool wait_for_client(void);
54 bool is_connected(void);
56 void set_on_close(bool on_close = true);
58 void set_worker(void *(*start)(void *data), void *(*running)(void *data), void *(*stop)(void *data));
60 void set_client_ctx(void *client_ctx);
63 bool recv(void *buffer, int len);
64 bool send(void *buffer, int len);
69 bool disconnect(void);
71 static void *thread_tcp_main(void *arg);
73 static void *worker_terminate(void *data);
80 sockaddr_in m_net_addr;
82 void *(*m_start)(void *data);
83 void *(*m_running)(void *data);
84 void *(*m_stop)(void *data);