ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SubNet.cpp
Revision: 1.7
Committed: Mon Jun 10 14:10:43 2002 UTC (22 years, 3 months ago) by tdb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +0 -0 lines
State: FILE REMOVED
Log Message:
Tidy up of files. These are all old things that are not only no longer used
but are also probably useless to anyone other than us. This saves checking
them out all the time, and makes the "cms/source" tree contain only current
stuff. They'll still exist in the attic's though :)

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org.uk
4 * Copyright (C) 2000-2002 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #include "SubNet.h"
22
23 SubNet::~SubNet(){
24
25 // free up any allocated memory
26 delete socket;
27 delete udp;
28
29 } // ~SubNet
30
31 SubNet::SubNet(string host, int port){
32 // constructor
33
34 // create a pointer to the object
35 socket = new iosockinet(sockbuf::sock_stream);
36
37 // make the actual connection
38 connect = (*socket).rdbuf()->connect(host.c_str(), port);
39
40 } // SubNet
41
42 int SubNet::isConnected(){
43
44 return connect;
45
46 } // isConnected
47
48
49 SubNet::SubNet(){
50 // no arg constructor
51
52 // connect to any socket on the local machine with the
53 // intention of getting sys information
54 socket = new iosockinet(sockbuf::sock_stream);
55 (*socket).rdbuf()->bind();
56
57 return;
58
59 } // SubNet
60
61 string SubNet::sendTCP(string text){
62
63 int size = 1024;
64 char buf[size];
65
66 (*socket) << text.c_str() << "\n" << flush; //
67
68 (*socket).getline(buf, size-1);
69
70 return buf;
71
72 } // sendTCP
73
74
75 void SubNet::sendUPDPacket( string host, int port, string message ){
76
77 int udpSize = sizeof(message.c_str());
78
79 udp = new osockinet(sockbuf::sock_dgram);
80 (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
81
82 (*udp)->connect (host.c_str(), port);
83 (*udp) << message.c_str() << flush;
84
85 delete udp;
86
87 return;
88
89 } // sendUPDPacket
90