#include <SocketUtils.h>
Public Member Functions | |
| SocketUtils (TROOT *serv, TMonitor *moni, TSocket *sock) | |
| ~SocketUtils () | |
| const string | getStringMessage () |
| const string | getHostname () |
| const string | getId () |
| void | closeSocket () |
Private Member Functions | |
| SocketUtils (const SocketUtils &su) | |
| SocketUtils & | operator= (const SocketUtils &su) |
Private Attributes | |
| TROOT * | _server |
| TMonitor * | _moni |
| TSocket * | _socket |
| string | _hostname |
| string | _id |
|
||||||||||||||||
|
Definition at line 29 of file SocketUtils.cc. References _hostname, _id, and port. 00030 : _server(serv), _moni(moni), _socket(sock), _id(":") 00031 { 00032 _hostname = string(sock->GetInetAddress().GetHostName()); 00033 int port = sock->GetInetAddress().GetPort(); 00034 char portChar[20]; 00035 sprintf(portChar, "%d", port); 00036 _id = _hostname + string(":") + string(portChar); 00037 00038 }
|
|
|
Definition at line 40 of file SocketUtils.cc. 00041 {
00042 }
|
|
|
|
|
|
Definition at line 86 of file SocketUtils.cc. References _moni, _server, and _socket. Referenced by getStringMessage(), DisplayServer::pollClients(), and DisplayServer::pollConsumer(). 00087 {
00088 // Close the socket, remove it from the socket lists and delete it.
00089 if ( _socket && (_socket != (TSocket*)-1) ) {
00090 if (_moni) _moni->Remove(_socket);
00091 _socket->Close();
00092 _server->GetListOfSockets()->Remove(_socket);
00093 delete _socket;
00094 _socket = 0;
00095 }
00096 else {
00097 cerr << "SocketUtils::closeSocket(): ERROR: _socket not valid." << endl;
00098 }
00099
00100 return;
00101 }
|
|
|
Definition at line 74 of file SocketUtils.cc. Referenced by DisplayServer::pollClients(). 00075 {
00076 return _hostname;
00077 }
|
|
|
Definition at line 80 of file SocketUtils.cc. Referenced by DisplayServer::pollClients(). 00081 {
00082 return _id;
00083 }
|
|
|
Definition at line 44 of file SocketUtils.cc. References _socket, and closeSocket(). Referenced by DisplayServer::pollClients(), and DisplayServer::pollConsumer(). 00045 {
00046 char* mess = 0;
00047 TMessage* clientMess = 0;
00048 Int_t recvRes = 0;
00049
00050 if ( _socket && (_socket != (TSocket*)-1) ) {
00051 recvRes = _socket->Recv(clientMess);
00052 if ((recvRes != -1) && (recvRes != 0)) {
00053 if (clientMess) {
00054 if (clientMess->What() == kMESS_STRING) {
00055 int messLength = clientMess->BufferSize() + 10;
00056 mess = new char[messLength];
00057 clientMess->ReadString(mess,messLength);
00058 }
00059 }
00060 else closeSocket();
00061 }
00062 else closeSocket();
00063 }
00064 delete clientMess;
00065 clientMess = 0;
00066 string clientString(mess);
00067 delete mess;
00068 mess = 0;
00069
00070 return clientString;
00071 }
|
|
|
|
|
|
Definition at line 48 of file SocketUtils.h. Referenced by SocketUtils(). |
|
|
Definition at line 49 of file SocketUtils.h. Referenced by SocketUtils(). |
|
|
Definition at line 46 of file SocketUtils.h. Referenced by closeSocket(). |
|
|
Definition at line 45 of file SocketUtils.h. Referenced by closeSocket(). |
|
|
Definition at line 47 of file SocketUtils.h. Referenced by closeSocket(), and getStringMessage(). |
1.3.9.1