aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd/socketchan.cc
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>1999-07-01 20:44:20 +0000
committerFritz Elfert <felfert@to.com>1999-07-01 20:44:20 +0000
commit80e566ea830ec9e6534f1a140af0bbc6b1765aa7 (patch)
tree86788a4b96d0b9ba70f787e4cd31777c4eb457bc /ncpd/socketchan.cc
parent8c29602b21efacced9d7ff4cd1f3c4101dda5f65 (diff)
downloadplptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.tar.gz
plptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.tar.bz2
plptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.zip
modified logging for finer control.
proper reconnect on link failure.
Diffstat (limited to 'ncpd/socketchan.cc')
-rw-r--r--ncpd/socketchan.cc123
1 files changed, 66 insertions, 57 deletions
diff --git a/ncpd/socketchan.cc b/ncpd/socketchan.cc
index 0afabf2..72ee298 100644
--- a/ncpd/socketchan.cc
+++ b/ncpd/socketchan.cc
@@ -30,76 +30,85 @@
#include "ppsocket.h"
#include "iowatch.h"
-socketChan::socketChan(ppsocket *_skt, ncp *_ncpController, IOWatch &_iow) :
- channel(_ncpController),
- iow(_iow)
+socketChan:: socketChan(ppsocket * _skt, ncp * _ncpController, IOWatch & _iow):
+channel(_ncpController),
+iow(_iow)
{
- skt = _skt;
- connectName = 0;
- iow.addIO(skt->socket());
- connected = false;
+ skt = _skt;
+ connectName = 0;
+ iow.addIO(skt->socket());
+ connected = false;
}
-socketChan::~socketChan() {
- iow.remIO(skt->socket());
- skt->closeSocket();
- delete skt;
- if (connectName) free(connectName);
+socketChan::~socketChan()
+{
+ iow.remIO(skt->socket());
+ skt->closeSocket();
+ delete skt;
+ if (connectName)
+ free(connectName);
}
-void socketChan::ncpDataCallback(bufferStore &a) {
- if (connectName != 0) {
- skt->sendBufferStore(a);
- }
- else {
- cerr << "This should not happen\n";
- }
+void socketChan::
+ncpDataCallback(bufferStore & a)
+{
+ if (connectName != 0) {
+ skt->sendBufferStore(a);
+ } else
+ cerr << "socketchan: Connect without name!!!\n";
}
-const char *socketChan::getNcpConnectName() {
- return connectName;
+const char *socketChan::
+getNcpConnectName()
+{
+ return connectName;
}
-void socketChan::ncpConnectAck() {
- bufferStore a;
- a.addStringT("Ok");
- skt->sendBufferStore(a);
- connected = true;
+void socketChan::
+ncpConnectAck()
+{
+ bufferStore a;
+ a.addStringT("Ok");
+ skt->sendBufferStore(a);
+ connected = true;
}
-void socketChan::ncpConnectTerminate() {
- bufferStore a;
- a.addStringT("Close");
- skt->sendBufferStore(a);
- terminateWhenAsked();
+void socketChan::
+ncpConnectTerminate()
+{
+ bufferStore a;
+ a.addStringT("Close");
+ skt->sendBufferStore(a);
+ terminateWhenAsked();
}
-void socketChan::socketPoll() {
- if (connectName == 0) {
- bufferStore a;
- if (skt->getBufferStore(a, false) == 1) {
- connectName = strdup(a.getString());
- ncpConnect();
- }
- }
- else if (connected) {
- bufferStore a;
- int res = skt->getBufferStore(a, false);
- if ( res == -1 ) {
- ncpDisconnect();
- }
- else if (res == 1) {
- if (a.getLen() > 5 &&
- !strncmp(a.getString(), "Close", 5)) {
- ncpDisconnect();
- }
- else {
- ncpSend(a);
- }
- }
- }
+void socketChan::
+socketPoll()
+{
+ if (connectName == 0) {
+ bufferStore a;
+ if (skt->getBufferStore(a, false) == 1) {
+ connectName = strdup(a.getString());
+ ncpConnect();
+ }
+ } else if (connected) {
+ bufferStore a;
+ int res = skt->getBufferStore(a, false);
+ if (res == -1) {
+ ncpDisconnect();
+ } else if (res == 1) {
+ if (a.getLen() > 5 &&
+ !strncmp(a.getString(), "Close", 5)) {
+ ncpDisconnect();
+ } else {
+ ncpSend(a);
+ }
+ }
+ }
}
-bool socketChan::isConnected() const {
- return connected;
+bool socketChan::
+isConnected()
+const {
+ return connected;
}