summaryrefslogtreecommitdiff
path: root/x11/ipc/server/ocopserver.cpp
Unidiff
Diffstat (limited to 'x11/ipc/server/ocopserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/server/ocopserver.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp
index 992cb8c..3ee38e9 100644
--- a/x11/ipc/server/ocopserver.cpp
+++ b/x11/ipc/server/ocopserver.cpp
@@ -70,97 +70,97 @@ void OCopServer::initSocket() {
70 /* cast to make it a (sockadr*) */ 70 /* cast to make it a (sockadr*) */
71 if (bind(m_serverfd, (struct sockaddr*)&m_address, m_adrlaenge ) == -1 ) { 71 if (bind(m_serverfd, (struct sockaddr*)&m_address, m_adrlaenge ) == -1 ) {
72 qWarning("Server could not bind try again"); 72 qWarning("Server could not bind try again");
73 close(m_serverfd); 73 close(m_serverfd);
74 QTimer::singleShot(400, this, SLOT(initSocket() ) ); 74 QTimer::singleShot(400, this, SLOT(initSocket() ) );
75 return; 75 return;
76 } 76 }
77 77
78 /* tell the kernel that we're listening and accepting 78 /* tell the kernel that we're listening and accepting
79 * 5 pending connections */ 79 * 5 pending connections */
80 if (listen(m_serverfd, 5) == -1 ) { 80 if (listen(m_serverfd, 5) == -1 ) {
81 qWarning("could not listen"); 81 qWarning("could not listen");
82 close(m_serverfd ); 82 close(m_serverfd );
83 QTimer::singleShot(400, this, SLOT(initSocket() ) ); 83 QTimer::singleShot(400, this, SLOT(initSocket() ) );
84 return; 84 return;
85 } 85 }
86 86
87 /* 87 /*
88 * now we will create two QSocketNotifier 88 * now we will create two QSocketNotifier
89 * which will us notify on reads 89 * which will us notify on reads
90 * and errors 90 * and errors
91 * we do this because they integrate 91 * we do this because they integrate
92 * nicely into the QApplication eventloop 92 * nicely into the QApplication eventloop
93 */ 93 */
94 m_server = new QSocketNotifier(m_serverfd, QSocketNotifier::Read, this ); 94 m_server = new QSocketNotifier(m_serverfd, QSocketNotifier::Read, this );
95 connect( m_server, SIGNAL(activated(int) ), 95 connect( m_server, SIGNAL(activated(int) ),
96 this, SLOT(newOnServer() ) ); 96 this, SLOT(newOnServer() ) );
97 97
98 m_serverError = new QSocketNotifier( m_serverfd, QSocketNotifier::Exception, this); 98 m_serverError = new QSocketNotifier( m_serverfd, QSocketNotifier::Exception, this);
99 connect(m_serverError, SIGNAL(activated(int) ), 99 connect(m_serverError, SIGNAL(activated(int) ),
100 this, SLOT(errorOnServer() ) ); 100 this, SLOT(errorOnServer() ) );
101 101
102 qWarning("done with registering"); 102 qWarning("done with registering");
103} 103}
104/** 104/**
105 * we got the possibility to read 105 * we got the possibility to read
106 * on the server 106 * on the server
107 * this is mostly due a connect 107 * this is mostly due a connect
108 * on a client side 108 * on a client side
109 * we will accept it 109 * we will accept it
110 * add it to our list 110 * add it to our list
111 */ 111 */
112void OCopServer::newOnServer() { 112void OCopServer::newOnServer() {
113 int fd = accept(); 113 int fd = accept();
114 if ( fd < 0 ) 114 if ( fd < 0 )
115 return; 115 return;
116 116
117 /* 117 /*
118 * we got a successfull new connection 118 * we got a successful new connection
119 * be happy 119 * be happy
120 * set SocketNotifier 120 * set SocketNotifier
121 * connect it 121 * connect it
122 * and a OCOPClient 122 * and a OCOPClient
123 */ 123 */
124// qWarning("Heureka new connection %d", fd ); 124// qWarning("Heureka new connection %d", fd );
125 125
126 126
127 registerClient( fd ); 127 registerClient( fd );
128} 128}
129int OCopServer::accept() { 129int OCopServer::accept() {
130 /* 130 /*
131 * accept it 131 * accept it
132 * the socket is currently blocking IIRC 132 * the socket is currently blocking IIRC
133 */ 133 */
134 return ::accept( m_serverfd, (struct sockaddr*)&m_address, &m_adrlaenge ); 134 return ::accept( m_serverfd, (struct sockaddr*)&m_address, &m_adrlaenge );
135} 135}
136void OCopServer::newOnClient( int fd ) { 136void OCopServer::newOnClient( int fd ) {
137 errno = 0; 137 errno = 0;
138 OCOPHead head; 138 OCOPHead head;
139 memset(&head, 0, sizeof(head) ); 139 memset(&head, 0, sizeof(head) );
140 int rea = ::read(fd, &head, sizeof(head) ); 140 int rea = ::read(fd, &head, sizeof(head) );
141 //qWarning("read %d %d", rea, errno); 141 //qWarning("read %d %d", rea, errno);
142 /* 142 /*
143 * I should get EPIPE but nothing like this happens 143 * I should get EPIPE but nothing like this happens
144 * so if rea == 0 and we were signaled by the notifier 144 * so if rea == 0 and we were signaled by the notifier
145 * we close it and drop the clients... 145 * we close it and drop the clients...
146 */ 146 */
147 if ( rea <= 0 ) { 147 if ( rea <= 0 ) {
148 deregisterClient( fd ); 148 deregisterClient( fd );
149 return; 149 return;
150 } 150 }
151 /* 151 /*
152 * OCOPHead 152 * OCOPHead
153 */ 153 */
154 //qWarning("data %s %d", &bug, rea ); 154 //qWarning("data %s %d", &bug, rea );
155 155
156 /* 156 /*
157 * Check the magic 157 * Check the magic
158 * if chcked read till EOF if magic does not match 158 * if chcked read till EOF if magic does not match
159 * otherwise do read 159 * otherwise do read
160 * channel 160 * channel
161 * func 161 * func
162 * data into mem 162 * data into mem
163 * and then send the OCOPPacket 163 * and then send the OCOPPacket
164 * 164 *
165 */ 165 */
166 if (head.magic == 47 ) { 166 if (head.magic == 47 ) {