|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef SERVERSOCKETCONNECTION_H |
|
19 #define SERVERSOCKETCONNECTION_H |
|
20 |
|
21 #include <pthread.h> |
|
22 #include <list> |
|
23 #include <sys/select.h> |
|
24 |
|
25 #include "javaosheaders.h" |
|
26 #include "scopedlocks.h" |
|
27 |
|
28 #include "serversocket.h" |
|
29 #include "transport.h" |
|
30 |
|
31 namespace java |
|
32 { |
|
33 namespace comms |
|
34 { |
|
35 |
|
36 class SocketConnection; |
|
37 |
|
38 OS_NONSHARABLE_CLASS(ServerSocketConnection) : public IpcServerConnectionInterface |
|
39 { |
|
40 public: |
|
41 ServerSocketConnection(IpcListener* aListener); |
|
42 virtual ~ServerSocketConnection(); |
|
43 |
|
44 // IpcServerConnectionInterface methods |
|
45 virtual int start(int aPort); |
|
46 virtual void stop(); |
|
47 virtual int send(ipcMessage_t* aMsg); |
|
48 |
|
49 private: |
|
50 static void* messageLoop(void* params); |
|
51 int select(); |
|
52 |
|
53 int handleNewConnection(fd_set& aSet); |
|
54 void handleRead(fd_set& aSet); |
|
55 void createSelectSet(fd_set& aSet, int& aMaxFd); |
|
56 void removeConnections(); |
|
57 |
|
58 pthread_t mThreadId; |
|
59 IpcListener* mListener; |
|
60 |
|
61 int mKeepRunning; |
|
62 ServerSocket mListenSocket; |
|
63 |
|
64 typedef std::list<SocketConnection*> connections_t; |
|
65 connections_t mSockets; // access protected by mSocketsMutex |
|
66 java::util::ScopedMutex mSocketsMutex; |
|
67 |
|
68 int mPort; |
|
69 }; |
|
70 |
|
71 } // namespace comms |
|
72 } // namespace java |
|
73 |
|
74 #endif // SERVERSOCKETCONNECTION_H |