blob: 773225e19f60e62e943c7b63c49799bfbb83168b [file] [log] [blame]
Marc Slemko6be374b2006-08-04 03:16:25 +00001#include <concurrency/ThreadManager.h>
2#include <concurrency/PosixThreadFactory.h>
3#include <protocol/TBinaryProtocol.h>
4#include <server/TSimpleServer.h>
Mark Slee0c2dff32007-03-09 19:26:57 +00005#include <server/TThreadedServer.h>
Marc Slemko6be374b2006-08-04 03:16:25 +00006#include <server/TThreadPoolServer.h>
Mark Sleeb9acf982006-10-10 01:57:32 +00007#include <server/TNonblockingServer.h>
Marc Slemko6be374b2006-08-04 03:16:25 +00008#include <transport/TServerSocket.h>
Mark Sleea3302652006-10-25 19:03:32 +00009#include <transport/TTransportUtils.h>
Mark Slee95771002006-06-07 06:53:25 +000010#include "ThriftTest.h"
Marc Slemko6be374b2006-08-04 03:16:25 +000011
12#include <iostream>
13#include <stdexcept>
14#include <sstream>
15
David Reissbc3dddb2007-08-22 23:20:24 +000016#define __STDC_FORMAT_MACROS
17#include <inttypes.h>
18
Mark Sleee8540632006-05-30 09:24:40 +000019using namespace std;
Mark Slee0c2dff32007-03-09 19:26:57 +000020using namespace boost;
Mark Sleee8540632006-05-30 09:24:40 +000021
Marc Slemko6be374b2006-08-04 03:16:25 +000022using namespace facebook::thrift;
Mark Slee0c2dff32007-03-09 19:26:57 +000023using namespace facebook::thrift::concurrency;
Marc Slemko6be374b2006-08-04 03:16:25 +000024using namespace facebook::thrift::protocol;
25using namespace facebook::thrift::transport;
26using namespace facebook::thrift::server;
27
Marc Slemkobf4fd192006-08-15 21:29:39 +000028using namespace thrift::test;
29
Mark Sleed2655522006-09-05 22:09:57 +000030class TestHandler : public ThriftTestIf {
Mark Sleee8540632006-05-30 09:24:40 +000031 public:
Mark Sleed2655522006-09-05 22:09:57 +000032 TestHandler() {}
Mark Sleee8540632006-05-30 09:24:40 +000033
34 void testVoid() {
35 printf("testVoid()\n");
36 }
37
Mark Slee1921d202007-01-24 19:43:06 +000038 void testString(string& out, const string &thing) {
Mark Sleee8540632006-05-30 09:24:40 +000039 printf("testString(\"%s\")\n", thing.c_str());
Mark Slee1921d202007-01-24 19:43:06 +000040 out = thing;
Mark Sleee8540632006-05-30 09:24:40 +000041 }
42
Mark Slee1921d202007-01-24 19:43:06 +000043 int8_t testByte(const int8_t thing) {
Mark Sleee8540632006-05-30 09:24:40 +000044 printf("testByte(%d)\n", (int)thing);
45 return thing;
46 }
47
Mark Slee1921d202007-01-24 19:43:06 +000048 int32_t testI32(const int32_t thing) {
Mark Sleee8540632006-05-30 09:24:40 +000049 printf("testI32(%d)\n", thing);
50 return thing;
51 }
52
Mark Slee1921d202007-01-24 19:43:06 +000053 int64_t testI64(const int64_t thing) {
David Reissbc3dddb2007-08-22 23:20:24 +000054 printf("testI64(%"PRId64")\n", thing);
Mark Sleee8540632006-05-30 09:24:40 +000055 return thing;
56 }
57
Mark Slee1921d202007-01-24 19:43:06 +000058 double testDouble(const double thing) {
Mark Sleec98d0502006-09-06 02:42:25 +000059 printf("testDouble(%lf)\n", thing);
60 return thing;
61 }
62
Mark Slee1921d202007-01-24 19:43:06 +000063 void testStruct(Xtruct& out, const Xtruct &thing) {
David Reissbc3dddb2007-08-22 23:20:24 +000064 printf("testStruct({\"%s\", %d, %d, %"PRId64"})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
Mark Slee1921d202007-01-24 19:43:06 +000065 out = thing;
Mark Sleee8540632006-05-30 09:24:40 +000066 }
67
Mark Slee1921d202007-01-24 19:43:06 +000068 void testNest(Xtruct2& out, const Xtruct2& nest) {
69 const Xtruct &thing = nest.struct_thing;
David Reissbc3dddb2007-08-22 23:20:24 +000070 printf("testNest({%d, {\"%s\", %d, %d, %"PRId64"}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
Mark Slee1921d202007-01-24 19:43:06 +000071 out = nest;
Mark Sleee8540632006-05-30 09:24:40 +000072 }
73
Mark Slee1921d202007-01-24 19:43:06 +000074 void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
Mark Sleee8540632006-05-30 09:24:40 +000075 printf("testMap({");
76 map<int32_t, int32_t>::const_iterator m_iter;
77 bool first = true;
78 for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
79 if (first) {
80 first = false;
81 } else {
82 printf(", ");
83 }
84 printf("%d => %d", m_iter->first, m_iter->second);
85 }
86 printf("})\n");
Mark Slee1921d202007-01-24 19:43:06 +000087 out = thing;
Mark Sleee8540632006-05-30 09:24:40 +000088 }
89
Mark Slee1921d202007-01-24 19:43:06 +000090 void testSet(set<int32_t> &out, const set<int32_t> &thing) {
Mark Sleee8540632006-05-30 09:24:40 +000091 printf("testSet({");
92 set<int32_t>::const_iterator s_iter;
93 bool first = true;
94 for (s_iter = thing.begin(); s_iter != thing.end(); ++s_iter) {
95 if (first) {
96 first = false;
97 } else {
98 printf(", ");
99 }
100 printf("%d", *s_iter);
101 }
102 printf("})\n");
Mark Slee1921d202007-01-24 19:43:06 +0000103 out = thing;
Mark Sleee8540632006-05-30 09:24:40 +0000104 }
105
Mark Slee1921d202007-01-24 19:43:06 +0000106 void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
Mark Sleee8540632006-05-30 09:24:40 +0000107 printf("testList({");
Mark Sleeb9acf982006-10-10 01:57:32 +0000108 vector<int32_t>::const_iterator l_iter;
Mark Sleee8540632006-05-30 09:24:40 +0000109 bool first = true;
110 for (l_iter = thing.begin(); l_iter != thing.end(); ++l_iter) {
111 if (first) {
112 first = false;
113 } else {
114 printf(", ");
115 }
116 printf("%d", *l_iter);
117 }
118 printf("})\n");
Mark Slee1921d202007-01-24 19:43:06 +0000119 out = thing;
Mark Sleee8540632006-05-30 09:24:40 +0000120 }
121
Mark Slee1921d202007-01-24 19:43:06 +0000122 Numberz testEnum(const Numberz thing) {
Mark Sleee8540632006-05-30 09:24:40 +0000123 printf("testEnum(%d)\n", thing);
124 return thing;
125 }
126
Mark Slee1921d202007-01-24 19:43:06 +0000127 UserId testTypedef(const UserId thing) {
David Reissbc3dddb2007-08-22 23:20:24 +0000128 printf("testTypedef(%"PRId64")\n", thing);
Mark Sleee8540632006-05-30 09:24:40 +0000129 return thing;
130 }
131
Mark Slee1921d202007-01-24 19:43:06 +0000132 void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
Mark Sleee8540632006-05-30 09:24:40 +0000133 printf("testMapMap(%d)\n", hello);
Mark Sleee8540632006-05-30 09:24:40 +0000134
135 map<int32_t,int32_t> pos;
136 map<int32_t,int32_t> neg;
137 for (int i = 1; i < 5; i++) {
138 pos.insert(make_pair(i,i));
139 neg.insert(make_pair(-i,-i));
140 }
141
142 mapmap.insert(make_pair(4, pos));
143 mapmap.insert(make_pair(-4, neg));
144
Mark Sleee8540632006-05-30 09:24:40 +0000145 }
146
Mark Slee1921d202007-01-24 19:43:06 +0000147 void testInsanity(map<UserId, map<Numberz,Insanity> > &insane, const Insanity &argument) {
Mark Sleee8540632006-05-30 09:24:40 +0000148 printf("testInsanity()\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000149
Mark Sleee8540632006-05-30 09:24:40 +0000150 Xtruct hello;
151 hello.string_thing = "Hello2";
152 hello.byte_thing = 2;
Mark Sleee8540632006-05-30 09:24:40 +0000153 hello.i32_thing = 2;
Mark Sleee8540632006-05-30 09:24:40 +0000154 hello.i64_thing = 2;
155
156 Xtruct goodbye;
157 goodbye.string_thing = "Goodbye4";
158 goodbye.byte_thing = 4;
Mark Sleee8540632006-05-30 09:24:40 +0000159 goodbye.i32_thing = 4;
Mark Sleee8540632006-05-30 09:24:40 +0000160 goodbye.i64_thing = 4;
161
162 Insanity crazy;
163 crazy.userMap.insert(make_pair(EIGHT, 8));
164 crazy.xtructs.push_back(goodbye);
165
166 Insanity looney;
167 crazy.userMap.insert(make_pair(FIVE, 5));
168 crazy.xtructs.push_back(hello);
169
170 map<Numberz, Insanity> first_map;
171 map<Numberz, Insanity> second_map;
172
173 first_map.insert(make_pair(TWO, crazy));
174 first_map.insert(make_pair(THREE, crazy));
175
176 second_map.insert(make_pair(SIX, looney));
177
Mark Sleee8540632006-05-30 09:24:40 +0000178 insane.insert(make_pair(1, first_map));
179 insane.insert(make_pair(2, second_map));
180
181 printf("return");
182 printf(" = {");
183 map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
184 for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
David Reissbc3dddb2007-08-22 23:20:24 +0000185 printf("%"PRId64" => {", i_iter->first);
Mark Sleee8540632006-05-30 09:24:40 +0000186 map<Numberz,Insanity>::const_iterator i2_iter;
187 for (i2_iter = i_iter->second.begin();
188 i2_iter != i_iter->second.end();
189 ++i2_iter) {
190 printf("%d => {", i2_iter->first);
191 map<Numberz, UserId> userMap = i2_iter->second.userMap;
192 map<Numberz, UserId>::const_iterator um;
193 printf("{");
194 for (um = userMap.begin(); um != userMap.end(); ++um) {
David Reissbc3dddb2007-08-22 23:20:24 +0000195 printf("%d => %"PRId64", ", um->first, um->second);
Mark Sleee8540632006-05-30 09:24:40 +0000196 }
197 printf("}, ");
198
Mark Sleeb9acf982006-10-10 01:57:32 +0000199 vector<Xtruct> xtructs = i2_iter->second.xtructs;
200 vector<Xtruct>::const_iterator x;
Mark Sleee8540632006-05-30 09:24:40 +0000201 printf("{");
202 for (x = xtructs.begin(); x != xtructs.end(); ++x) {
David Reissbc3dddb2007-08-22 23:20:24 +0000203 printf("{\"%s\", %d, %d, %"PRId64"}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
Mark Sleee8540632006-05-30 09:24:40 +0000204 }
205 printf("}");
206
207 printf("}, ");
208 }
209 printf("}, ");
210 }
211 printf("}\n");
212
David Reiss0c90f6f2008-02-06 22:18:40 +0000213
Mark Sleee8540632006-05-30 09:24:40 +0000214 }
Marc Slemkoe6889de2006-08-12 00:32:53 +0000215
Mark Slee1921d202007-01-24 19:43:06 +0000216 void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz arg4, const UserId arg5) {
Marc Slemkoe6889de2006-08-12 00:32:53 +0000217 printf("testMulti()\n");
David Reiss0c90f6f2008-02-06 22:18:40 +0000218
Marc Slemkoe6889de2006-08-12 00:32:53 +0000219 hello.string_thing = "Hello2";
220 hello.byte_thing = arg0;
221 hello.i32_thing = arg1;
222 hello.i64_thing = (int64_t)arg2;
Marc Slemkoe6889de2006-08-12 00:32:53 +0000223 }
Marc Slemkobf4fd192006-08-15 21:29:39 +0000224
Mark Slee1921d202007-01-24 19:43:06 +0000225 void testException(const std::string &arg) throw(Xception) {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000226 printf("testException(%s)\n", arg.c_str());
Mark Sleed3d733a2006-09-01 22:19:06 +0000227 if (arg.compare("Xception") == 0) {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000228 Xception e;
229 e.errorCode = 1001;
230 e.message = "This is an Xception";
231 throw e;
232 } else {
233 Xtruct result;
234 result.string_thing = arg;
235 return;
236 }
237 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000238
Mark Slee1921d202007-01-24 19:43:06 +0000239 void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000240
Marc Slemko71d4e472006-08-15 22:34:04 +0000241 printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
Marc Slemkobf4fd192006-08-15 21:29:39 +0000242
Mark Sleef5f2be42006-09-05 21:05:31 +0000243 if (arg0.compare("Xception") == 0) {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000244 Xception e;
245 e.errorCode = 1001;
246 e.message = "This is an Xception";
247 throw e;
Mark Sleef5f2be42006-09-05 21:05:31 +0000248 } else if (arg0.compare("Xception2") == 0) {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000249 Xception2 e;
250 e.errorCode = 2002;
251 e.struct_thing.string_thing = "This is an Xception2";
252 throw e;
253 } else {
Marc Slemkobf4fd192006-08-15 21:29:39 +0000254 result.string_thing = arg1;
Mark Slee1921d202007-01-24 19:43:06 +0000255 return;
Marc Slemkobf4fd192006-08-15 21:29:39 +0000256 }
257 }
Mark Sleee8540632006-05-30 09:24:40 +0000258};
259
260int main(int argc, char **argv) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000261
Mark Sleee8540632006-05-30 09:24:40 +0000262 int port = 9090;
Marc Slemko6be374b2006-08-04 03:16:25 +0000263 string serverType = "simple";
264 string protocolType = "binary";
265 size_t workerCount = 4;
Mark Sleea3302652006-10-25 19:03:32 +0000266 bool frameOutput = true;
Marc Slemko6be374b2006-08-04 03:16:25 +0000267
268 ostringstream usage;
269
270 usage <<
271 argv[0] << " [--port=<port number>] [--server-type=<server-type>] [--protocol-type=<protocol-type>] [--workers=<worker-count>]" << endl <<
272
Mark Slee0c2dff32007-03-09 19:26:57 +0000273 "\t\tserver-type\t\ttype of server, \"simple\", \"thread-pool\", \"threaded\", or \"nonblocking\". Default is " << serverType << endl <<
Marc Slemko6be374b2006-08-04 03:16:25 +0000274
275 "\t\tprotocol-type\t\ttype of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl <<
276
277 "\t\tworkers\t\tNumber of thread pools workers. Only valid for thread-pool server type. Default is " << workerCount << endl;
David Reiss0c90f6f2008-02-06 22:18:40 +0000278
Marc Slemko6be374b2006-08-04 03:16:25 +0000279 map<string, string> args;
David Reiss0c90f6f2008-02-06 22:18:40 +0000280
Mark Sleef5f2be42006-09-05 21:05:31 +0000281 for (int ix = 1; ix < argc; ix++) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000282 string arg(argv[ix]);
Mark Sleef5f2be42006-09-05 21:05:31 +0000283 if (arg.compare(0,2, "--") == 0) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000284 size_t end = arg.find_first_of("=", 2);
Mark Sleef5f2be42006-09-05 21:05:31 +0000285 if (end != string::npos) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000286 args[string(arg, 2, end - 2)] = string(arg, end + 1);
287 } else {
Mark Sleea3302652006-10-25 19:03:32 +0000288 args[string(arg, 2)] = "true";
Marc Slemko6be374b2006-08-04 03:16:25 +0000289 }
Marc Slemko6be374b2006-08-04 03:16:25 +0000290 } else {
291 throw invalid_argument("Unexcepted command line token: "+arg);
292 }
Mark Sleee8540632006-05-30 09:24:40 +0000293 }
Marc Slemko6be374b2006-08-04 03:16:25 +0000294
295 try {
296
Mark Sleef5f2be42006-09-05 21:05:31 +0000297 if (!args["port"].empty()) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000298 port = atoi(args["port"].c_str());
299 }
300
Mark Sleea3302652006-10-25 19:03:32 +0000301 if (!args["noframe"].empty()) {
302 frameOutput = false;
303 }
304
Mark Sleef5f2be42006-09-05 21:05:31 +0000305 if (!args["server-type"].empty()) {
David Reiss0c90f6f2008-02-06 22:18:40 +0000306 serverType = args["server-type"];
Mark Sleef5f2be42006-09-05 21:05:31 +0000307 if (serverType == "simple") {
308 } else if (serverType == "thread-pool") {
Mark Slee0c2dff32007-03-09 19:26:57 +0000309 } else if (serverType == "threaded") {
Mark Sleeb9acf982006-10-10 01:57:32 +0000310 } else if (serverType == "nonblocking") {
Marc Slemko6be374b2006-08-04 03:16:25 +0000311 } else {
Marc Slemko6be374b2006-08-04 03:16:25 +0000312 throw invalid_argument("Unknown server type "+serverType);
313 }
314 }
315
Mark Sleef5f2be42006-09-05 21:05:31 +0000316 if (!args["protocol-type"].empty()) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000317 protocolType = args["protocol-type"];
Mark Sleef5f2be42006-09-05 21:05:31 +0000318 if (protocolType == "binary") {
319 } else if (protocolType == "ascii") {
Marc Slemko6be374b2006-08-04 03:16:25 +0000320 throw invalid_argument("ASCII protocol not supported");
Mark Sleef5f2be42006-09-05 21:05:31 +0000321 } else if (protocolType == "xml") {
Marc Slemko6be374b2006-08-04 03:16:25 +0000322 throw invalid_argument("XML protocol not supported");
323 } else {
324 throw invalid_argument("Unknown protocol type "+protocolType);
325 }
David Reiss0c90f6f2008-02-06 22:18:40 +0000326 }
Marc Slemko6be374b2006-08-04 03:16:25 +0000327
Mark Sleef5f2be42006-09-05 21:05:31 +0000328 if (!args["workers"].empty()) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000329 workerCount = atoi(args["workers"].c_str());
330 }
Mark Sleef5f2be42006-09-05 21:05:31 +0000331 } catch (exception& e) {
Marc Slemko6be374b2006-08-04 03:16:25 +0000332 cerr << e.what() << endl;
333 cerr << usage;
334 }
335
Mark Sleee8540632006-05-30 09:24:40 +0000336 // Dispatcher
Mark Sleea3302652006-10-25 19:03:32 +0000337 shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
Marc Slemko6be374b2006-08-04 03:16:25 +0000338
Mark Sleed2655522006-09-05 22:09:57 +0000339 shared_ptr<TestHandler> testHandler(new TestHandler());
340
Mark Sleea3302652006-10-25 19:03:32 +0000341 shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler));
Mark Sleee8540632006-05-30 09:24:40 +0000342
Mark Sleee8540632006-05-30 09:24:40 +0000343 // Transport
Marc Slemko6be374b2006-08-04 03:16:25 +0000344 shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
Mark Sleee8540632006-05-30 09:24:40 +0000345
Mark Sleed788b2e2006-09-07 01:26:35 +0000346 // Factory
347 shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
348
Mark Sleed3d733a2006-09-01 22:19:06 +0000349 if (serverType == "simple") {
Mark Sleee8540632006-05-30 09:24:40 +0000350
Marc Slemko6be374b2006-08-04 03:16:25 +0000351 // Server
Mark Slee018b6992006-09-07 21:31:12 +0000352 TSimpleServer simpleServer(testProcessor,
Mark Sleed788b2e2006-09-07 01:26:35 +0000353 serverSocket,
354 transportFactory,
Mark Sleea3302652006-10-25 19:03:32 +0000355 protocolFactory);
Marc Slemko6be374b2006-08-04 03:16:25 +0000356
357 printf("Starting the server on port %d...\n", port);
Mark Slee794993d2006-09-20 01:56:10 +0000358 simpleServer.serve();
Marc Slemko6be374b2006-08-04 03:16:25 +0000359
Mark Sleed3d733a2006-09-01 22:19:06 +0000360 } else if (serverType == "thread-pool") {
Marc Slemko6be374b2006-08-04 03:16:25 +0000361
Mark Sleef5f2be42006-09-05 21:05:31 +0000362 shared_ptr<ThreadManager> threadManager =
363 ThreadManager::newSimpleThreadManager(workerCount);
Marc Slemko6be374b2006-08-04 03:16:25 +0000364
Mark Sleef5f2be42006-09-05 21:05:31 +0000365 shared_ptr<PosixThreadFactory> threadFactory =
366 shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
Marc Slemko6be374b2006-08-04 03:16:25 +0000367
368 threadManager->threadFactory(threadFactory);
369
370 threadManager->start();
371
Mark Slee018b6992006-09-07 21:31:12 +0000372 TThreadPoolServer threadPoolServer(testProcessor,
Marc Slemko6be374b2006-08-04 03:16:25 +0000373 serverSocket,
Mark Sleed788b2e2006-09-07 01:26:35 +0000374 transportFactory,
Mark Sleea3302652006-10-25 19:03:32 +0000375 protocolFactory,
376 threadManager);
Marc Slemko6be374b2006-08-04 03:16:25 +0000377
378 printf("Starting the server on port %d...\n", port);
Mark Slee794993d2006-09-20 01:56:10 +0000379 threadPoolServer.serve();
Mark Sleeb9acf982006-10-10 01:57:32 +0000380
Mark Slee0c2dff32007-03-09 19:26:57 +0000381 } else if (serverType == "threaded") {
David Reiss0c90f6f2008-02-06 22:18:40 +0000382
Mark Slee0c2dff32007-03-09 19:26:57 +0000383 TThreadedServer threadedServer(testProcessor,
384 serverSocket,
385 transportFactory,
386 protocolFactory);
387
388 printf("Starting the server on port %d...\n", port);
389 threadedServer.serve();
390
Mark Sleeb9acf982006-10-10 01:57:32 +0000391 } else if (serverType == "nonblocking") {
392
Mark Sleea3302652006-10-25 19:03:32 +0000393 TNonblockingServer nonblockingServer(testProcessor, port);
394 nonblockingServer.setFrameResponses(frameOutput);
395 if (frameOutput) {
396 printf("Using framed output mode\n");
397 } else {
398 printf("Using non-framed output mode\n");
399 }
400
Mark Sleeb9acf982006-10-10 01:57:32 +0000401 printf("Starting the nonblocking server on port %d...\n", port);
402 nonblockingServer.serve();
403
Marc Slemko6be374b2006-08-04 03:16:25 +0000404 }
405
Mark Sleee8540632006-05-30 09:24:40 +0000406 printf("done.\n");
407 return 0;
408}