├── .gitignore
├── BarebonesClient
├── Barebones_Client.sln
└── Barebones_Client
│ ├── Barebones_Client.vcxproj
│ ├── Barebones_Client.vcxproj.filters
│ └── main.cpp
├── BarebonesServer
├── BarebonesServer.sln
└── BarebonesServer
│ ├── BarebonesServer.vcxproj
│ ├── BarebonesServer.vcxproj.filters
│ └── main.cpp
├── MultipleClientsBarebonesServer
├── MultipleClientsBarebonesServer.sln
└── MultipleClientsBarebonesServer
│ ├── BarebonesServer.vcxproj.filters
│ ├── MultipleClientsBarebonesServer.vcxproj
│ └── main.cpp
├── MultipleClientsBarebonesServerUDP
├── MultipleClientsBarebonesServer.sln
└── MultipleClientsBarebonesServer
│ ├── BarebonesServer.vcxproj.filters
│ ├── MultipleClientsBarebonesServer.vcxproj
│ └── main.cpp
├── QOTDServer
├── QOTDServer.sln
└── QOTDServer
│ ├── QOTDServer.vcxproj
│ ├── QOTDServer.vcxproj.filters
│ ├── Qotd.cpp
│ ├── Qotd.h
│ ├── TcpListener.cpp
│ ├── TcpListener.h
│ ├── main.cpp
│ └── wisdom.txt
├── README.md
└── UDPClientServerBasic
├── UDP_Client
├── UDP_Client.sln
└── UDP_Client
│ ├── UDP_Client.vcxproj
│ ├── UDP_Client.vcxproj.filters
│ └── main.cpp
└── UDP_Server
├── UDP_Server.sln
└── UDP_Server
├── UDP_Server.vcxproj
├── UDP_Server.vcxproj.filters
└── main.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/BarebonesClient/Barebones_Client.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Barebones_Client", "Barebones_Client\Barebones_Client.vcxproj", "{DBB9CA79-1E8A-4AE7-8841-B1636DB11247}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Debug|x64.ActiveCfg = Debug|x64
17 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Debug|x64.Build.0 = Debug|x64
18 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Debug|x86.ActiveCfg = Debug|Win32
19 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Debug|x86.Build.0 = Debug|Win32
20 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Release|x64.ActiveCfg = Release|x64
21 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Release|x64.Build.0 = Release|x64
22 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Release|x86.ActiveCfg = Release|Win32
23 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/BarebonesClient/Barebones_Client/Barebones_Client.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {DBB9CA79-1E8A-4AE7-8841-B1636DB11247}
23 | Barebones_Client_2017
24 | 8.1
25 |
26 |
27 |
28 | Application
29 | true
30 | v140
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v140
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v140
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v140
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 |
78 |
79 |
80 |
81 | Level3
82 | Disabled
83 | true
84 |
85 |
86 |
87 |
88 | Level3
89 | MaxSpeed
90 | true
91 | true
92 | true
93 |
94 |
95 | true
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | MaxSpeed
103 | true
104 | true
105 | true
106 |
107 |
108 | true
109 | true
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/BarebonesClient/Barebones_Client/Barebones_Client.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/BarebonesClient/Barebones_Client/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #pragma comment(lib, "ws2_32.lib")
5 |
6 | using namespace std;
7 |
8 | void main()
9 | {
10 | string ipAddress = "127.0.0.1"; // IP Address of the server
11 | int port = 54000; // Listening port # on the server
12 |
13 | // Initialize WinSock
14 | WSAData data;
15 | WORD ver = MAKEWORD(2, 2);
16 | int wsResult = WSAStartup(ver, &data);
17 | if (wsResult != 0)
18 | {
19 | cerr << "Can't start Winsock, Err #" << wsResult << endl;
20 | return;
21 | }
22 |
23 | // Create socket
24 | SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
25 | if (sock == INVALID_SOCKET)
26 | {
27 | cerr << "Can't create socket, Err #" << WSAGetLastError() << endl;
28 | WSACleanup();
29 | return;
30 | }
31 |
32 | // Fill in a hint structure
33 | sockaddr_in hint;
34 | hint.sin_family = AF_INET;
35 | hint.sin_port = htons(port);
36 | inet_pton(AF_INET, ipAddress.c_str(), &hint.sin_addr);
37 |
38 | // Connect to server
39 | int connResult = connect(sock, (sockaddr*)&hint, sizeof(hint));
40 | if (connResult == SOCKET_ERROR)
41 | {
42 | cerr << "Can't connect to server, Err #" << WSAGetLastError() << endl;
43 | closesocket(sock);
44 | WSACleanup();
45 | return;
46 | }
47 |
48 | // Do-while loop to send and receive data
49 | char buf[4096];
50 | string userInput;
51 |
52 | do
53 | {
54 | // Prompt the user for some text
55 | cout << "> ";
56 | getline(cin, userInput);
57 |
58 | if (userInput.size() > 0) // Make sure the user has typed in something
59 | {
60 | // Send the text
61 | int sendResult = send(sock, userInput.c_str(), userInput.size() + 1, 0);
62 | if (sendResult != SOCKET_ERROR)
63 | {
64 | // Wait for response
65 | ZeroMemory(buf, 4096);
66 | int bytesReceived = recv(sock, buf, 4096, 0);
67 | if (bytesReceived > 0)
68 | {
69 | // Echo response to console
70 | cout << "SERVER> " << string(buf, 0, bytesReceived) << endl;
71 | }
72 | }
73 | }
74 |
75 | } while (userInput.size() > 0);
76 |
77 | // Gracefully close down everything
78 | closesocket(sock);
79 | WSACleanup();
80 | }
81 |
--------------------------------------------------------------------------------
/BarebonesServer/BarebonesServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BarebonesServer", "BarebonesServer\BarebonesServer.vcxproj", "{6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.ActiveCfg = Debug|x64
17 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.Build.0 = Debug|x64
18 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.ActiveCfg = Debug|Win32
19 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.Build.0 = Debug|Win32
20 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.ActiveCfg = Release|x64
21 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.Build.0 = Release|x64
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.ActiveCfg = Release|Win32
23 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/BarebonesServer/BarebonesServer/BarebonesServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}
23 | BarebonesServer
24 | 10.0
25 |
26 |
27 |
28 | Application
29 | true
30 | v142
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v142
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v142
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v142
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 |
78 |
79 |
80 |
81 | Level3
82 | Disabled
83 | true
84 |
85 |
86 |
87 |
88 | Level3
89 | MaxSpeed
90 | true
91 | true
92 | true
93 |
94 |
95 | true
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | MaxSpeed
103 | true
104 | true
105 | true
106 |
107 |
108 | true
109 | true
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/BarebonesServer/BarebonesServer/BarebonesServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/BarebonesServer/BarebonesServer/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #pragma comment (lib, "ws2_32.lib")
6 |
7 | using namespace std;
8 |
9 | void ShowLastError();
10 |
11 | void main()
12 | {
13 | // Initialze winsock
14 | WSADATA wsData;
15 | WORD ver = MAKEWORD(2, 2);
16 |
17 | int wsOk = WSAStartup(ver, &wsData);
18 | if (wsOk != 0)
19 | {
20 | cerr << "Can't Initialize winsock! Quitting" << endl;
21 | return;
22 | }
23 |
24 | // Create a socket
25 | SOCKET listening = socket(AF_INET, SOCK_STREAM, 0);
26 | if (listening == INVALID_SOCKET)
27 | {
28 | cerr << "Can't create a socket! Quitting" << endl;
29 | return;
30 | }
31 |
32 | // Bind the ip address and port to a socket
33 | sockaddr_in hint;
34 | hint.sin_family = AF_INET;
35 | hint.sin_port = htons(54000);
36 | hint.sin_addr.S_un.S_addr = INADDR_ANY; // Could also use inet_pton ....
37 |
38 | if (bind(listening, (sockaddr*)&hint, sizeof(hint)) == SOCKET_ERROR)
39 | {
40 | ShowLastError();
41 | return;
42 | }
43 |
44 | // Tell Winsock the socket is for listening
45 | listen(listening, SOMAXCONN);
46 |
47 | // Wait for a connection
48 | sockaddr_in client;
49 | int clientSize = sizeof(client);
50 |
51 | SOCKET clientSocket = accept(listening, (sockaddr*)&client, &clientSize);
52 |
53 | char host[NI_MAXHOST]; // Client's remote name
54 | char service[NI_MAXSERV]; // Service (i.e. port) the client is connect on
55 |
56 | ZeroMemory(host, NI_MAXHOST); // same as memset(host, 0, NI_MAXHOST);
57 | ZeroMemory(service, NI_MAXSERV);
58 |
59 | if (getnameinfo((sockaddr*)&client, sizeof(client), host, NI_MAXHOST, service, NI_MAXSERV, 0) == 0)
60 | {
61 | cout << host << " connected on port " << service << endl;
62 | }
63 | else
64 | {
65 | inet_ntop(AF_INET, &client.sin_addr, host, NI_MAXHOST);
66 | cout << host << " connected on port " <<
67 | ntohs(client.sin_port) << endl;
68 | }
69 |
70 | // Close listening socket
71 | closesocket(listening);
72 |
73 | // While loop: accept and echo message back to client
74 | char buf[4096];
75 |
76 | while (true)
77 | {
78 | ZeroMemory(buf, 4096);
79 |
80 | // Wait for client to send data
81 | int bytesReceived = recv(clientSocket, buf, 4096, 0);
82 | if (bytesReceived == SOCKET_ERROR)
83 | {
84 | cerr << "Error in recv(). Quitting" << endl;
85 | break;
86 | }
87 |
88 | if (bytesReceived == 0)
89 | {
90 | cout << "Client disconnected " << endl;
91 | break;
92 | }
93 |
94 | cout << string(buf, 0, bytesReceived) << endl;
95 |
96 | // Echo message back to client
97 | send(clientSocket, buf, bytesReceived + 1, 0);
98 |
99 | }
100 |
101 | // Close the socket
102 | closesocket(clientSocket);
103 |
104 | // Cleanup winsock
105 | WSACleanup();
106 |
107 | system("pause");
108 | }
109 |
110 | void ShowLastError()
111 | {
112 | wchar_t* s = NULL;
113 | FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
114 | FORMAT_MESSAGE_FROM_SYSTEM |
115 | FORMAT_MESSAGE_IGNORE_INSERTS,
116 | NULL,
117 | WSAGetLastError(),
118 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
119 | (LPWSTR)&s, 0, NULL);
120 | fprintf(stderr, "%S\n", s);
121 | LocalFree(s);
122 | }
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultipleClientsBarebonesServer", "MultipleClientsBarebonesServer\MultipleClientsBarebonesServer.vcxproj", "{6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.ActiveCfg = Debug|x64
17 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.Build.0 = Debug|x64
18 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.ActiveCfg = Debug|Win32
19 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.Build.0 = Debug|Win32
20 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.ActiveCfg = Release|x64
21 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.Build.0 = Release|x64
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.ActiveCfg = Release|Win32
23 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer/BarebonesServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}
23 | BarebonesServer
24 | 8.1
25 |
26 |
27 |
28 | Application
29 | true
30 | v140
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v140
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v140
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v140
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 |
78 |
79 |
80 |
81 | Level3
82 | Disabled
83 | true
84 |
85 |
86 |
87 |
88 | Level3
89 | MaxSpeed
90 | true
91 | true
92 | true
93 |
94 |
95 | true
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | MaxSpeed
103 | true
104 | true
105 | true
106 |
107 |
108 | true
109 | true
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #pragma comment (lib, "ws2_32.lib")
7 |
8 | using namespace std;
9 |
10 | void main()
11 | {
12 | // Initialze winsock
13 | WSADATA wsData;
14 | WORD ver = MAKEWORD(2, 2);
15 |
16 | int wsOk = WSAStartup(ver, &wsData);
17 | if (wsOk != 0)
18 | {
19 | cerr << "Can't Initialize winsock! Quitting" << endl;
20 | return;
21 | }
22 |
23 | // Create a socket
24 | SOCKET listening = socket(AF_INET, SOCK_STREAM, 0);
25 | if (listening == INVALID_SOCKET)
26 | {
27 | cerr << "Can't create a socket! Quitting" << endl;
28 | return;
29 | }
30 |
31 | // Bind the ip address and port to a socket
32 | sockaddr_in hint;
33 | hint.sin_family = AF_INET;
34 | hint.sin_port = htons(54000);
35 | hint.sin_addr.S_un.S_addr = INADDR_ANY; // Could also use inet_pton ....
36 |
37 | bind(listening, (sockaddr*)&hint, sizeof(hint));
38 |
39 | // Tell Winsock the socket is for listening
40 | listen(listening, SOMAXCONN);
41 |
42 | // Create the master file descriptor set and zero it
43 | fd_set master;
44 | FD_ZERO(&master);
45 |
46 | // Add our first socket that we're interested in interacting with; the listening socket!
47 | // It's important that this socket is added for our server or else we won't 'hear' incoming
48 | // connections
49 | FD_SET(listening, &master);
50 |
51 | // this will be changed by the \quit command (see below, bonus not in video!)
52 | bool running = true;
53 |
54 | while (running)
55 | {
56 | // Make a copy of the master file descriptor set, this is SUPER important because
57 | // the call to select() is _DESTRUCTIVE_. The copy only contains the sockets that
58 | // are accepting inbound connection requests OR messages.
59 |
60 | // E.g. You have a server and it's master file descriptor set contains 5 items;
61 | // the listening socket and four clients. When you pass this set into select(),
62 | // only the sockets that are interacting with the server are returned. Let's say
63 | // only one client is sending a message at that time. The contents of 'copy' will
64 | // be one socket. You will have LOST all the other sockets.
65 |
66 | // SO MAKE A COPY OF THE MASTER LIST TO PASS INTO select() !!!
67 |
68 | fd_set copy = master;
69 |
70 | // See who's talking to us
71 | int socketCount = select(0, ©, nullptr, nullptr, nullptr);
72 |
73 | // Loop through all the current connections / potential connect
74 | for (int i = 0; i < socketCount; i++)
75 | {
76 | // Makes things easy for us doing this assignment
77 | SOCKET sock = copy.fd_array[i];
78 |
79 | // Is it an inbound communication?
80 | if (sock == listening)
81 | {
82 | // Accept a new connection
83 | SOCKET client = accept(listening, nullptr, nullptr);
84 |
85 | // Add the new connection to the list of connected clients
86 | FD_SET(client, &master);
87 |
88 | // Send a welcome message to the connected client
89 | string welcomeMsg = "Welcome to the Awesome Chat Server!\r\n";
90 | send(client, welcomeMsg.c_str(), welcomeMsg.size() + 1, 0);
91 | }
92 | else // It's an inbound message
93 | {
94 | char buf[4096];
95 | ZeroMemory(buf, 4096);
96 |
97 | // Receive message
98 | int bytesIn = recv(sock, buf, 4096, 0);
99 | if (bytesIn <= 0)
100 | {
101 | // Drop the client
102 | closesocket(sock);
103 | FD_CLR(sock, &master);
104 | }
105 | else
106 | {
107 | // Check to see if it's a command. \quit kills the server
108 | if (buf[0] == '\\')
109 | {
110 | // Is the command quit?
111 | string cmd = string(buf, bytesIn);
112 | if (cmd == "\\quit")
113 | {
114 | running = false;
115 | break;
116 | }
117 |
118 | // Unknown command
119 | continue;
120 | }
121 |
122 | // Send message to other clients, and definiately NOT the listening socket
123 |
124 | for (int i = 0; i < master.fd_count; i++)
125 | {
126 | SOCKET outSock = master.fd_array[i];
127 | if (outSock != listening && outSock != sock)
128 | {
129 | ostringstream ss;
130 | ss << "SOCKET #" << sock << ": " << buf << "\r\n";
131 | string strOut = ss.str();
132 |
133 | send(outSock, strOut.c_str(), strOut.size() + 1, 0);
134 | }
135 | }
136 | }
137 | }
138 | }
139 | }
140 |
141 | // Remove the listening socket from the master file descriptor set and close it
142 | // to prevent anyone else trying to connect.
143 | FD_CLR(listening, &master);
144 | closesocket(listening);
145 |
146 | // Message to let users know what's happening.
147 | string msg = "Server is shutting down. Goodbye\r\n";
148 |
149 | while (master.fd_count > 0)
150 | {
151 | // Get the socket number
152 | SOCKET sock = master.fd_array[0];
153 |
154 | // Send the goodbye message
155 | send(sock, msg.c_str(), msg.size() + 1, 0);
156 |
157 | // Remove it from the master file list and close the socket
158 | FD_CLR(sock, &master);
159 | closesocket(sock);
160 | }
161 |
162 | // Cleanup winsock
163 | WSACleanup();
164 |
165 | system("pause");
166 | }
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServerUDP/MultipleClientsBarebonesServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MultipleClientsBarebonesServer", "MultipleClientsBarebonesServer\MultipleClientsBarebonesServer.vcxproj", "{6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.ActiveCfg = Debug|x64
17 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x64.Build.0 = Debug|x64
18 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.ActiveCfg = Debug|Win32
19 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Debug|x86.Build.0 = Debug|Win32
20 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.ActiveCfg = Release|x64
21 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x64.Build.0 = Release|x64
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.ActiveCfg = Release|Win32
23 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServerUDP/MultipleClientsBarebonesServer/BarebonesServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServerUDP/MultipleClientsBarebonesServer/MultipleClientsBarebonesServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {6F7D20E1-C9CC-441D-BE7A-95527A2A2D76}
23 | BarebonesServer
24 | 10.0
25 |
26 |
27 |
28 | Application
29 | true
30 | v142
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v142
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v142
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v142
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 |
78 |
79 |
80 |
81 | Level3
82 | Disabled
83 | true
84 |
85 |
86 |
87 |
88 | Level3
89 | MaxSpeed
90 | true
91 | true
92 | true
93 |
94 |
95 | true
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | MaxSpeed
103 | true
104 | true
105 | true
106 |
107 |
108 | true
109 | true
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/MultipleClientsBarebonesServerUDP/MultipleClientsBarebonesServer/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #pragma comment (lib, "ws2_32.lib")
7 |
8 | using namespace std;
9 |
10 | void main()
11 | {
12 | // Initialze winsock
13 | WSADATA wsData;
14 | WORD ver = MAKEWORD(2, 2);
15 |
16 | int wsOk = WSAStartup(ver, &wsData);
17 | if (wsOk != 0)
18 | {
19 | cerr << "Can't Initialize winsock! Quitting" << endl;
20 | return;
21 | }
22 |
23 | // Create a socket
24 | SOCKET listening = socket(AF_INET, SOCK_DGRAM, 0);
25 | if (listening == INVALID_SOCKET)
26 | {
27 | cerr << "Can't create a socket! Quitting" << endl;
28 | return;
29 | }
30 |
31 | // Bind the ip address and port to a socket
32 | sockaddr_in hint;
33 | hint.sin_family = AF_INET;
34 | hint.sin_port = htons(54000);
35 | hint.sin_addr.S_un.S_addr = INADDR_ANY; // Could also use inet_pton ....
36 |
37 | bind(listening, (sockaddr*)&hint, sizeof(hint));
38 |
39 | // Tell Winsock the socket is for listening
40 | listen(listening, SOMAXCONN);
41 |
42 | // Create the master file descriptor set and zero it
43 | fd_set master;
44 | FD_ZERO(&master);
45 |
46 | // Add our first socket that we're interested in interacting with; the listening socket!
47 | // It's important that this socket is added for our server or else we won't 'hear' incoming
48 | // connections
49 | FD_SET(listening, &master);
50 |
51 | // this will be changed by the \quit command (see below, bonus not in video!)
52 | bool running = true;
53 |
54 | while (running)
55 | {
56 | // Make a copy of the master file descriptor set, this is SUPER important because
57 | // the call to select() is _DESTRUCTIVE_. The copy only contains the sockets that
58 | // are accepting inbound connection requests OR messages.
59 |
60 | // E.g. You have a server and it's master file descriptor set contains 5 items;
61 | // the listening socket and four clients. When you pass this set into select(),
62 | // only the sockets that are interacting with the server are returned. Let's say
63 | // only one client is sending a message at that time. The contents of 'copy' will
64 | // be one socket. You will have LOST all the other sockets.
65 |
66 | // SO MAKE A COPY OF THE MASTER LIST TO PASS INTO select() !!!
67 |
68 | fd_set copy = master;
69 |
70 | // See who's talking to us
71 | int socketCount = select(0, ©, nullptr, nullptr, nullptr);
72 |
73 | // Loop through all the current connections / potential connect
74 | for (int i = 0; i < socketCount; i++)
75 | {
76 | // Makes things easy for us doing this assignment
77 | SOCKET sock = copy.fd_array[i];
78 |
79 | // Is it an inbound communication?
80 | if (sock == listening)
81 | {
82 | // Accept a new connection
83 | //SOCKET client = accept(listening, nullptr, nullptr);
84 | sockaddr_in client_address;
85 | int address_length = sizeof(struct sockaddr);
86 | char buf[4096];
87 | int bytes = recvfrom(sock, buf, 4096, 0, (struct sockaddr*)&client_address, &address_length);
88 | cout << buf << endl;
89 | }
90 | else // It's an inbound message
91 | {
92 | char buf[4096];
93 | ZeroMemory(buf, 4096);
94 |
95 | // Receive message
96 | int bytesIn = recv(sock, buf, 4096, 0);
97 | if (bytesIn <= 0)
98 | {
99 | // Drop the client
100 | closesocket(sock);
101 | FD_CLR(sock, &master);
102 | }
103 | else
104 | {
105 | // Check to see if it's a command. \quit kills the server
106 | if (buf[0] == '\\')
107 | {
108 | // Is the command quit?
109 | string cmd = string(buf, bytesIn);
110 | if (cmd == "\\quit")
111 | {
112 | running = false;
113 | break;
114 | }
115 |
116 | // Unknown command
117 | continue;
118 | }
119 |
120 | // Send message to other clients, and definiately NOT the listening socket
121 |
122 | for (int i = 0; i < master.fd_count; i++)
123 | {
124 | SOCKET outSock = master.fd_array[i];
125 | if (outSock != listening && outSock != sock)
126 | {
127 | ostringstream ss;
128 | ss << "SOCKET #" << sock << ": " << buf << "\r\n";
129 | string strOut = ss.str();
130 |
131 | send(outSock, strOut.c_str(), strOut.size() + 1, 0);
132 | }
133 | }
134 | }
135 | }
136 | }
137 | }
138 |
139 | // Remove the listening socket from the master file descriptor set and close it
140 | // to prevent anyone else trying to connect.
141 | FD_CLR(listening, &master);
142 | closesocket(listening);
143 |
144 | // Message to let users know what's happening.
145 | string msg = "Server is shutting down. Goodbye\r\n";
146 |
147 | while (master.fd_count > 0)
148 | {
149 | // Get the socket number
150 | SOCKET sock = master.fd_array[0];
151 |
152 | // Send the goodbye message
153 | send(sock, msg.c_str(), msg.size() + 1, 0);
154 |
155 | // Remove it from the master file list and close the socket
156 | FD_CLR(sock, &master);
157 | closesocket(sock);
158 | }
159 |
160 | // Cleanup winsock
161 | WSACleanup();
162 |
163 | system("pause");
164 | }
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListenerProject", "ListenerProject\ListenerProject.vcxproj", "{19398658-9420-49E8-A108-A8A8357C0EF8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Debug|x64.ActiveCfg = Debug|x64
17 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Debug|x64.Build.0 = Debug|x64
18 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Debug|x86.ActiveCfg = Debug|Win32
19 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Debug|x86.Build.0 = Debug|Win32
20 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Release|x64.ActiveCfg = Release|x64
21 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Release|x64.Build.0 = Release|x64
22 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Release|x86.ActiveCfg = Release|Win32
23 | {19398658-9420-49E8-A108-A8A8357C0EF8}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/QOTDServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {19398658-9420-49E8-A108-A8A8357C0EF8}
23 | ListenerProject
24 | 8.1
25 |
26 |
27 |
28 | Application
29 | true
30 | v140
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v140
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v140
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v140
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 |
78 |
79 |
80 |
81 | Level3
82 | Disabled
83 | true
84 |
85 |
86 |
87 |
88 | Level3
89 | MaxSpeed
90 | true
91 | true
92 | true
93 |
94 |
95 | true
96 | true
97 |
98 |
99 |
100 |
101 | Level3
102 | MaxSpeed
103 | true
104 | true
105 | true
106 |
107 |
108 | true
109 | true
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/QOTDServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/Qotd.cpp:
--------------------------------------------------------------------------------
1 | #include "Qotd.h"
2 |
3 | // Constructor
4 | CQotd::CQotd(std::string filename)
5 | {
6 | std::ifstream file;
7 | file.open(filename);
8 | if (file.is_open())
9 | {
10 | std::string line;
11 | std::string running = "";
12 |
13 | while (getline(file, line))
14 | {
15 | if (line != "%")
16 | {
17 | running = running + line + "\n";
18 | }
19 | else
20 | {
21 | quotes.push_back(running);
22 | running = "";
23 | }
24 | }
25 | }
26 | }
27 |
28 | // Get a random quote from the file
29 | std::string CQotd::GetRandomQuote()
30 | {
31 | int r = rand() % quotes.size();
32 | return quotes[r];
33 | }
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/Qotd.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | class CQotd
8 | {
9 | public:
10 |
11 | // Constructor
12 | CQotd(std::string filename);
13 |
14 | // Get a random quote from the file
15 | std::string GetRandomQuote();
16 |
17 | private:
18 |
19 | // The quotes
20 | std::vector quotes;
21 | };
22 |
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/TcpListener.cpp:
--------------------------------------------------------------------------------
1 | #include "TcpListener.h"
2 |
3 | CTcpListener::CTcpListener(std::string ipAddress, int port, MessageRecievedHandler handler)
4 | : m_ipAddress(ipAddress), m_port(port), MessageReceived(handler)
5 | {
6 |
7 | }
8 |
9 | CTcpListener::~CTcpListener()
10 | {
11 | Cleanup();
12 | }
13 |
14 | // Send a message to the specified client
15 | void CTcpListener::Send(int clientSocket, std::string msg)
16 | {
17 | send(clientSocket, msg.c_str(), msg.size() + 1, 0);
18 | }
19 |
20 | // Initialize winsock
21 | bool CTcpListener::Init()
22 | {
23 | WSAData data;
24 | WORD ver = MAKEWORD(2, 2);
25 |
26 | int wsInit = WSAStartup(ver, &data);
27 | // TODO: Inform caller the error that occured
28 |
29 | return wsInit == 0;
30 | }
31 |
32 | // The main processing loop
33 | void CTcpListener::Run()
34 | {
35 | char buf[MAX_BUFFER_SIZE];
36 |
37 | while (true)
38 | {
39 | // Create a listening socket
40 | SOCKET listening = CreateSocket();
41 | if (listening == INVALID_SOCKET)
42 | {
43 | break;
44 | }
45 |
46 | SOCKET client = WaitForConnection(listening);
47 | if (client != INVALID_SOCKET)
48 | {
49 | closesocket(listening);
50 |
51 | int bytesReceived = 0;
52 | do
53 | {
54 | ZeroMemory(buf, MAX_BUFFER_SIZE);
55 |
56 | bytesReceived = recv(client, buf, MAX_BUFFER_SIZE, 0);
57 | if (bytesReceived > 0)
58 | {
59 | if (MessageReceived != NULL)
60 | {
61 | MessageReceived(this, client, std::string(buf, 0, bytesReceived));
62 | }
63 | }
64 |
65 | } while (bytesReceived > 0);
66 |
67 | closesocket(client);
68 | }
69 | }
70 | }
71 |
72 | void CTcpListener::Cleanup()
73 | {
74 | WSACleanup();
75 | }
76 |
77 | // Create a socket
78 | SOCKET CTcpListener::CreateSocket()
79 | {
80 | SOCKET listening = socket(AF_INET, SOCK_STREAM, 0);
81 | if (listening != INVALID_SOCKET)
82 | {
83 | sockaddr_in hint;
84 | hint.sin_family = AF_INET;
85 | hint.sin_port = htons(m_port);
86 | inet_pton(AF_INET, m_ipAddress.c_str(), &hint.sin_addr);
87 |
88 | int bindOk = bind(listening, (sockaddr*)&hint, sizeof(hint));
89 | if (bindOk != SOCKET_ERROR)
90 | {
91 | int listenOk = listen(listening, SOMAXCONN);
92 | if (listenOk == SOCKET_ERROR)
93 | {
94 | return -1;
95 | }
96 | }
97 | else
98 | {
99 | return -1;
100 | }
101 | }
102 |
103 | return listening;
104 | }
105 |
106 | // Wait for a connection
107 | SOCKET CTcpListener::WaitForConnection(SOCKET listening)
108 | {
109 | SOCKET client = accept(listening, NULL, NULL);
110 | return client;
111 | }
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/TcpListener.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include // Header file for Winsock functions
5 | #pragma comment(lib, "ws2_32.lib") // Winsock library file
6 |
7 | #define MAX_BUFFER_SIZE (49152)
8 |
9 | // Forward declaration of class
10 | class CTcpListener;
11 |
12 | // Callback to data received
13 | typedef void(*MessageRecievedHandler)(CTcpListener* listener, int socketId, std::string msg);
14 |
15 | class CTcpListener
16 | {
17 |
18 | public:
19 |
20 | // Constructor
21 | CTcpListener(std::string ipAddress, int port, MessageRecievedHandler handler);
22 |
23 | // Destructor
24 | ~CTcpListener();
25 |
26 | // Send a message to the specified client
27 | void Send(int clientSocket, std::string msg);
28 |
29 | // Initialize winsock
30 | bool Init();
31 |
32 | // The main processing loop
33 | void Run();
34 |
35 | // Clean up after using the service
36 | void Cleanup();
37 |
38 | private:
39 |
40 | // Create a socket
41 | SOCKET CreateSocket();
42 |
43 | // Wait for a connection
44 | SOCKET WaitForConnection(SOCKET listening);
45 |
46 | // Address of the server
47 | std::string m_ipAddress;
48 |
49 | // Listening port
50 | int m_port;
51 |
52 | // Message received event handler
53 | MessageRecievedHandler MessageReceived;
54 | };
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "TcpListener.h"
5 | #include "Qotd.h"
6 |
7 | using namespace std;
8 |
9 | void Listener_MessageReceived(CTcpListener* listener, int client, string msg);
10 |
11 | // This is kinda bad because it's global.
12 | CQotd quotes("wisdom.txt");
13 |
14 | void main()
15 | {
16 | CTcpListener server("127.0.0.1", 54010, Listener_MessageReceived);
17 |
18 | if (server.Init())
19 | {
20 | server.Run();
21 | }
22 | }
23 |
24 | void Listener_MessageReceived(CTcpListener* listener, int client, string msg)
25 | {
26 | if (msg == "QUOTE")
27 | {
28 | listener->Send(client, quotes.GetRandomQuote());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/QOTDServer/QOTDServer/wisdom.txt:
--------------------------------------------------------------------------------
1 | (1) Avoid fried meats which angry up the blood.
2 | (2) If your stomach antagonizes you, pacify it with cool thoughts.
3 | (3) Keep the juices flowing by jangling around gently as you move.
4 | (4) Go very lightly on the vices, such as carrying on in society, as
5 | the social ramble ain't restful.
6 | (5) Avoid running at all times.
7 | (6) Don't look back, something might be gaining on you.
8 | -- S. Paige, c. 1951
9 | %
10 | A clash of doctrine is not a disaster -- it is an opportunity.
11 | %
12 | A cloud does not know why it moves in just such a direction and at such
13 | a speed, if feels an impulsion... this is the place to go now. But the
14 | sky knows the reasons and the patterns behind all clouds, and you will
15 | know, too, when you lift yourself high enough to see beyond horizons.
16 | -- Messiah's Handbook : Reminders for the Advanced Soul
17 | %
18 | A dream will always triumph over reality, once it is given the chance.
19 | -- Stanislaw Lem
20 | %
21 | A fake fortuneteller can be tolerated. But an authentic soothsayer should
22 | be shot on sight. Cassandra did not get half the kicking around she deserved.
23 | -- R.A. Heinlein
24 | %
25 | A halted retreat
26 | Is nerve-wracking and dangerous.
27 | To retain people as men -- and maidservants
28 | Brings good fortune.
29 | %
30 | A lifetime isn't nearly long enough to figure out what it's all about.
31 | %
32 | A lot of people I know believe in positive thinking, and so do I. I
33 | believe everything positively stinks.
34 | -- Lew Col
35 | %
36 | A man said to the Universe:
37 | "Sir, I exist!"
38 | "However," replied the Universe,
39 | "the fact has not created in me a sense of obligation."
40 | -- Stephen Crane
41 | %
42 | A master was asked the question, "What is the Way?" by a curious monk.
43 | "It is right before your eyes," said the master.
44 | "Why do I not see it for myself?"
45 | "Because you are thinking of yourself."
46 | "What about you: do you see it?"
47 | "So long as you see double, saying `I don't', and `you do', and so
48 | on, your eyes are clouded," said the master.
49 | "When there is neither `I' nor `You', can one see it?"
50 | "When there is neither `I' nor `You',
51 | who is the one that wants to see it?"
52 | %
53 | A neighbor came to Nasrudin, asking to borrow his donkey. "It is out on
54 | loan," the teacher replied. At that moment, the donkey brayed loudly inside
55 | the stable. "But I can hear it bray, over there." "Whom do you believe,"
56 | asked Nasrudin, "me or a donkey?"
57 | %
58 | A priest advised Voltaire on his death bed to renounce the devil.
59 | Replied Voltaire, "This is no time to make new enemies."
60 | %
61 | A priest asked: What is Fate, Master?
62 | And the Master answered:
63 | It is that which gives a beast of burden its reason for existence.
64 | It is that which men in former times had to bear upon their backs.
65 | It is that which has caused nations to build byways from City
66 | to City upon which carts and coaches pass, and alongside which inns
67 | have come to be built to stave off Hunger, Thirst and Weariness.
68 | And that is Fate? said the priest.
69 | Fate... I thought you said Freight, responded the Master.
70 | That's all right, said the priest. I wanted to know
71 | what Freight was too.
72 | -- Kehlog Albran, "The Profit"
73 | %
74 | A sad spectacle. If they be inhabited, what a scope for misery and folly.
75 | If they be not inhabited, what a waste of space.
76 | -- Thomas Carlyle, looking at the stars
77 | %
78 | A Scholar asked his Master, "Master, would you advise me of a proper
79 | vocation?"
80 | The Master replied, "Some men can earn their keep with the power of
81 | their minds. Others must use thier strong backs, legs and hands. This is
82 | the same in nature as it is with man. Some animals acquire their food easily,
83 | such as rabbits, hogs and goats. Other animals must fiercely struggle for
84 | their sustenance, like beavers, moles and ants. So you see, the nature of
85 | the vocation must fit the individual.
86 | "But I have no abilities, desires, or imagination, Master," the
87 | scholar sobbed.
88 | Queried the Master... "Have you thought of becoming a salesperson?"
89 | %
90 | A thing is not necessarily true because a man dies for it.
91 | -- Oscar Wilde, "The Portrait of Mr. W.H."
92 | %
93 | A would-be disciple came to Nasrudin's hut on the mountain-side. Knowing
94 | that every action of such an enlightened one is significant, the seeker
95 | watched the teacher closely. "Why do you blow on your hands?" "To warm
96 | myself in the cold." Later, Nasrudin poured bowls of hot soup for himself
97 | and the newcomer, and blew on his own. "Why are you doing that, Master?"
98 | "To cool the soup." Unable to trust a man who uses the same process
99 | to arrive at two different results -- hot and cold -- the disciple departed.
100 | %
101 | Ah, but a man's grasp should exceed his reach,
102 | Or what's a heaven for ?
103 | -- Robert Browning, "Andrea del Sarto"
104 | %
105 | All hope abandon, ye who enter here!
106 | -- Dante Alighieri
107 | %
108 | All men know the utility of useful things;
109 | but they do not know the utility of futility.
110 | -- Chuang-tzu
111 | %
112 | All of the true things I am about to tell you are shameless lies.
113 | -- The Book of Bokonon / Kurt Vonnegut Jr.
114 | %
115 | All of us should treasure his Oriental wisdom and his preaching of a
116 | Zen-like detachment, as exemplified by his constant reminder to clerks,
117 | tellers, or others who grew excited by his presence in their banks:
118 | "Just lie down on the floor and keep calm."
119 | -- Robert Wilson, "John Dillinger Died for You"
120 | %
121 | An idea is an eye given by God for the seeing of God. Some of these eyes
122 | we cannot bear to look out of, we blind them as quickly as possible.
123 | -- Russell Hoban, "Pilgermann"
124 | %
125 | An idea is not responsible for the people who believe in it.
126 | %
127 | An older student came to Otis and said, "I have been to see a
128 | great number of teachers and I have given up a great number of pleasures.
129 | I have fasted, been celibate and stayed awake nights seeking enlightenment.
130 | I have given up everything I was asked to give up and I have suffered, but
131 | I have not been enlightened. What should I do?"
132 | Otis replied, "Give up suffering."
133 | -- Camden Benares, "Zen Without Zen Masters"
134 | %
135 | And ever has it been known that love knows not its own depth until the
136 | hour of separation.
137 | -- Kahlil Gibran
138 | %
139 | Anyway, I keep picturing all these little kids playing some game in this
140 | big field of rye and all. Thousands of little kids, and nobody's around --
141 | nobody big, I mean -- except me. And I'm standing on the edge of some crazy
142 | cliff. What I have to do, I have to catch everybody if they start to go
143 | over the cliff -- I mean if they're running and they don't look where they're
144 | going I have to come out from somewhere and catch them. That's all I'd do
145 | all day. I'd just be the catcher in the rye. I know it; I know it's crazy,
146 | but that's the only thing I'd really like to be. I know it's crazy.
147 | -- J.D. Salinger, "Catcher in the Rye"
148 | %
149 | Approaching the gates of the monastery, Hakuin found Ken the Zen
150 | preaching to a group of disciples.
151 | "Words..." Ken orated, "they are but an illusory veil obfuscating
152 | the absolute reality of --"
153 | "Ken!" Hakuin interrupted. "Your fly is down!"
154 | Whereupon the Clear Light of Illumination exploded upon Ken, and he
155 | vaporized.
156 | On the way to town, Hakuin was greeted by an itinerant monk imbued
157 | with the spirit of the morning.
158 | "Ah," the monk sighed, a beatific smile wrinkling across his cheeks,
159 | "Thou art That..."
160 | "Ah," Hakuin replied, pointing excitedly, "And Thou art Fat!"
161 | Whereupon the Clear Light of Illumination exploded upon the monk,
162 | and he vaporized.
163 | Next, the Governor sought the advice of Hakuin, crying: "As our
164 | enemies bear down upon us, how shall I, with such heartless and callow
165 | soldiers as I am heir to, hope to withstand the impending onslaught?"
166 | "US?" snapped Hakuin.
167 | Whereupon the Clear Light of Illumination exploded upon the
168 | Governor, and he vaporized.
169 | Then, a redneck went up to Hakuin and vaporized the old Master with
170 | his shotgun. "Ha! Beat ya' to the punchline, ya' scrawny li'l geek!"
171 | %
172 | Arrakis teaches the attitude of the knife - chopping off what's
173 | incomplete and saying: "Now it's complete because it's ended here."
174 | -- Muad'dib, "Dune"
175 | %
176 | As failures go, attempting to recall the past is like trying to grasp
177 | the meaning of existence. Both make one feel like a baby clutching at
178 | a basketball: one's palms keep sliding off.
179 | -- Joseph Brodsky
180 | %
181 | At ebb tide I wrote a line upon the sand, and gave it all my heart and all
182 | my soul. At flood tide I returned to read what I had inscribed and found my
183 | ignorance upon the shore.
184 | -- Kahlil Gibran
185 | %
186 | At the end of your life there'll be a good rest, and no further activities
187 | are scheduled.
188 | %
189 | At the foot of the mountain, thunder:
190 | The image of Providing Nourishment.
191 | Thus the superior man is careful of his words
192 | And temperate in eating and drinking.
193 | %
194 | Beauty is one of the rare things which does not lead to doubt of God.
195 | -- Jean Anouilh
196 | %
197 | Before he became a hermit, Zarathud was a young Priest, and
198 | took great delight in making fools of his opponents in front of
199 | his followers.
200 | One day Zarathud took his students to a pleasant pasture and
201 | there he confronted The Sacred Chao while She was contentedly grazing.
202 | "Tell me, you dumb beast," demanded the Priest in his
203 | commanding voice, "why don't you do something worthwhile? What is your
204 | Purpose in Life, anyway?"
205 | Munching the tasty grass, The Sacred Chao replied "MU". (The
206 | Chinese ideogram for NO-THING.)
207 | Upon hearing this, absolutely nobody was enlightened.
208 | Primarily because nobody understood Chinese.
209 | -- Camden Benares, "Zen Without Zen Masters"
210 | %
211 | Before you ask more questions, think about whether you really want to
212 | know the answers.
213 | -- Gene Wolfe, "The Claw of the Conciliator"
214 | %
215 | Brahma said: Well, after hearing ten thousand explanations, a fool is no
216 | wiser. But an intelligent man needs only two thousand five hundred.
217 | -- The Mahabharata
218 | %
219 | By protracting life, we do not deduct one jot from the duration of death.
220 | -- Titus Lucretius Carus
221 | %
222 | Catharsis is something I associate with pornography and crossword puzzles.
223 | -- Howard Chaykin
224 | %
225 | Certainly the game is rigged.
226 |
227 | Don't let that stop you; if you don't bet, you can't win.
228 | -- Robert Heinlein, "Time Enough For Love"
229 | %
230 | Chance is perhaps the work of God when He did not want to sign.
231 | -- Anatole France
232 | %
233 | Chapter 1
234 |
235 | The story so far:
236 |
237 | In the beginning the Universe was created. This has made a lot
238 | of people very angry and been widely regarded as a bad move.
239 | -- Douglas Adams?
240 | %
241 | "Cheshire-Puss," she began, "would you tell me, please, which way I
242 | ought to go from here?"
243 | "That depends a good deal on where you want to get to," said the Cat.
244 | "I don't care much where--" said Alice.
245 | "Then it doesn't matter which way you go," said the Cat.
246 | %
247 | Circumstances rule men; men do not rule circumstances.
248 | -- Herodotus
249 | %
250 | Coincidences are spiritual puns.
251 | -- G.K. Chesterton
252 | %
253 | Death is a spirit leaving a body, sort of like a shell leaving the nut behind.
254 | -- Erma Bombeck
255 | %
256 | Death is God's way of telling you not to be such a wise guy.
257 | %
258 | Death is life's way of telling you you've been fired.
259 | -- R. Geis
260 | %
261 | Death is Nature's way of recycling human beings.
262 | %
263 | Death is nature's way of saying `Howdy'.
264 | %
265 | Death is nature's way of telling you to slow down.
266 | %
267 | Death is only a state of mind.
268 |
269 | Only it doesn't leave you much time to think about anything else.
270 | %
271 | Depart not from the path which fate has assigned you.
272 | %
273 | Depend on the rabbit's foot if you will, but remember, it didn't help
274 | the rabbit.
275 | -- R.E. Shay
276 | %
277 | Destiny is a good thing to accept when it's going your way. When it isn't,
278 | don't call it destiny; call it injustice, treachery, or simple bad luck.
279 | -- Joseph Heller, "God Knows"
280 | %
281 | Disease can be cured; fate is incurable.
282 | -- Chinese proverb
283 | %
284 | Ditat Deus.
285 | [God enriches]
286 | %
287 | Do not believe in miracles -- rely on them.
288 | %
289 | Do not despair of life. You have no doubt force enough to overcome your
290 | obstacles. Think of the fox prowling through wood and field in a winter night
291 | for something to satisfy his hunger. Notwithstanding cold and hounds and
292 | traps, his race survives. I do not believe any of them ever committed suicide.
293 | -- Henry David Thoreau
294 | %
295 | Do not seek death; death will find you. But seek the road which makes death
296 | a fulfillment.
297 | -- Dag Hammarskjold
298 | %
299 | Do not take life too seriously; you will never get out of it alive.
300 | %
301 | Do what you can to prolong your life, in the hope that someday you'll
302 | learn what it's for.
303 | %
304 | "Do you think there's a God?"
305 | "Well, ____SOMEbody's out to get me!"
306 | -- Calvin and Hobbs
307 | %
308 | Do your part to help preserve life on Earth -- by trying to preserve your own.
309 | %
310 | Don't abandon hope. Your Captain Midnight decoder ring arrives tomorrow.
311 | %
312 | Don't abandon hope: your Tom Mix decoder ring arrives tomorrow.
313 | %
314 | Don't go to bed with no price on your head.
315 | -- Baretta
316 | %
317 | Don't have good ideas if you aren't willing to be responsible for them.
318 | %
319 | Don't kid yourself. Little is relevant, and nothing lasts forever.
320 | %
321 | Don't let people drive you crazy when you know it's in walking distance.
322 | %
323 | Don't make a big deal out of everything; just deal with everything.
324 | %
325 | Don't stop to stomp ants when the elephants are stampeding.
326 | %
327 | Don't take life seriously, you'll never get out alive.
328 | %
329 | Doubt isn't the opposite of faith; it is an element of faith.
330 | -- Paul Tillich, German theologian.
331 | %
332 | Down with categorical imperative!
333 | %
334 | Due to circumstances beyond your control, you are master of your fate
335 | and captain of your soul.
336 | %
337 | During the voyage of life, remember to keep an eye out for a fair wind; batten
338 | down during a storm; hail all passing ships; and fly your colors proudly.
339 | %
340 | Dying is a very dull, dreary affair. My advice to you is to have
341 | nothing whatever to do with it.
342 | -- W. Somerset Maughm, his last words
343 | %
344 | Dying is one of the few things that can be done as easily lying down.
345 | -- Woody Allen
346 | %
347 | Each man is his own prisoner, in solitary confinement for life.
348 | %
349 | Each of us bears his own Hell.
350 | -- Publius Vergilius Maro (Virgil)
351 | %
352 | Either I'm dead or my watch has stopped.
353 | -- Groucho Marx's last words
354 | %
355 | Even the best of friends cannot attend each other's funeral.
356 | -- Kehlog Albran, "The Profit"
357 | %
358 | Every man who has reached even his intellectual teens begins to suspect
359 | that life is no farce; that it is not genteel comedy even; that it flowers
360 | and fructifies on the contrary out of the profoundest tragic depths of the
361 | essential death in which its subject's roots are plunged. The natural
362 | inheritance of everyone who is capable of spiritual life is an unsubdued
363 | forest where the wolf howls and the obscene bird of night chatters.
364 | -- Henry James Sr., writing to his sons Henry and William
365 | %
366 | Every person, all the events in your life are there because you have
367 | drawn them there. What you choose to do with them is up to you.
368 | -- Messiah's Handbook : Reminders for the Advanced Soul
369 | %
370 | Everything ends badly. Otherwise it wouldn't end.
371 | %
372 | Everything in this book may be wrong.
373 | -- Messiah's Handbook : Reminders for the Advanced Soul
374 | %
375 | Everything is possible. Pass the word.
376 | -- Rita Mae Brown, "Six of One"
377 | %
378 | Execute every act of thy life as though it were thy last.
379 | -- Marcus Aurelius
380 | %
381 | Expansion means complexity; and complexity decay.
382 | %
383 | Facts are the enemy of truth.
384 | -- Don Quixote
385 | %
386 | Fain would I climb, yet fear I to fall.
387 | -- Sir Walter Raleigh
388 | %
389 | Faith goes out through the window when beauty comes in at the door.
390 | %
391 | Faith is under the left nipple.
392 | -- Martin Luther
393 | %
394 | Fill what's empty, empty what's full, scratch where it itches.
395 | -- Alice Roosevelt Longworth
396 | %
397 | ... "fire" does not matter, "earth" and "air" and "water" do not matter.
398 | "I" do not matter. No word matters. But man forgets reality and remembers
399 | words. The more words he remembers, the cleverer do his fellows esteem him.
400 | He looks upon the great transformations of the world, but he does not see
401 | them as they were seen when man looked upon reality for the first time.
402 | Their names come to his lips and he smiles as he tastes them, thinking he
403 | knows them in the naming.
404 | -- Roger Zelazny, "Lord of Light"
405 | %
406 | For fast-acting relief, try slowing down.
407 | %
408 | For good, return good.
409 | For evil, return justice.
410 | %
411 | For if there is a sin against life, it consists perhaps not so much in
412 | despairing of life as in hoping for another life and in eluding the
413 | implacable grandeur of this life.
414 | -- Albert Camus
415 | %
416 | For your penance, say five Hail Marys and one loud BLAH!
417 | %
418 | Force has no place where there is need of skill.
419 | -- Herodotus
420 | %
421 | FORTUNE'S RULES TO LIVE BY: #2
422 | Never goose a wolverine.
423 | %
424 | FORTUNE'S RULES TO LIVE BY: #23
425 | Don't cut off a police car when making an illegal U-turn.
426 | %
427 | From listening comes wisdom and from speaking repentance.
428 | %
429 | From the cradle to the coffin underwear comes first.
430 | -- Bertolt Brecht
431 | %
432 | Generally speaking, the Way of the warrior is resolute acceptance of death.
433 | -- Miyamoto Musashi, 1645
434 | %
435 | Getting into trouble is easy.
436 | -- D. Winkel and F. Prosser
437 | %
438 | Getting there is only half as far as getting there and back.
439 | %
440 | Given a choice between grief and nothing, I'd choose grief.
441 | -- William Faulkner
442 | %
443 | God grant us the serenity to accept the things we cannot change, courage to
444 | change the things we can, and wisdom to know the difference.
445 | %
446 | God instructs the heart, not by ideas, but by pains and contradictions.
447 | -- De Caussade
448 | %
449 | God is the tangential point between zero and infinity.
450 | -- Alfred Jarry
451 | %
452 | God made everything out of nothing, but the nothingness shows through.
453 | -- Paul Valery
454 | %
455 | Good-bye. I am leaving because I am bored.
456 | -- George Saunders' dying words
457 | %
458 | Goodbye, cool world.
459 | %
460 | Got a dictionary? I want to know the meaning of life.
461 | %
462 | Great acts are made up of small deeds.
463 | -- Lao Tsu
464 | %
465 | **** GROWTH CENTER REPAIR SERVICE
466 |
467 | For those who have had too much of Esalen, Topanga, and Kairos. Tired of
468 | being genuine all the time? Would you like to learn how to be a little
469 | phony again? Have you disclosed so much that you're beginning to avoid
470 | people? Have you touched so many people that they're all beginning to
471 | feel the same? Like to be a little dependent? Are perfect orgasms
472 | beginning to bore you? Would you like, for once, not to express a
473 | feeling? Or better yet, not be in touch with it at all? Come to us. We
474 | promise to relieve you of the burden of your great potential.
475 | %
476 | Happiness is having a scratch for every itch.
477 | -- Ogden Nash
478 | %
479 | Happiness is just an illusion, filled with sadness and confusion.
480 | %
481 | Happiness isn't having what you want, it's wanting what you have.
482 | %
483 | Happiness isn't something you experience; it's something you remember.
484 | -- Oscar Levant
485 | %
486 | Having the fewest wants, I am nearest to the gods.
487 | -- Socrates
488 | %
489 | He has shown you, o man, what is good. And what does the Lord ask of you,
490 | but to do justice, and to love kindness, and to walk humbly before your God?
491 | %
492 | He is truly wise who gains wisdom from another's mishap.
493 | %
494 | He knows not how to know who knows not also how to unknow.
495 | -- Sir Richard Burton
496 | %
497 | He that composes himself is wiser than he that composes a book.
498 | -- B. Franklin
499 | %
500 | He thought of Musashi, the Sword Saint, standing in his garden more than
501 | three hundred years ago. "What is the 'Body of a rock'?" he was asked.
502 | In answer, Musashi summoned a pupil of his and bid him kill himself by
503 | slashing his abdomen with a knife. Just as the pupil was about to comply,
504 | the Master stayed his hand, saying, "That is the 'Body of a rock'."
505 | -- Eric Van Lustbader
506 | %
507 | He who despairs over an event is a coward, but he who holds hopes for
508 | the human condition is a fool.
509 | -- Albert Camus
510 | %
511 | He who knows not and knows that he knows not is ignorant. Teach him.
512 | He who knows not and knows not that he knows not is a fool. Shun him.
513 | He who knows and knows not that he knows is asleep. Wake him.
514 | %
515 | He who knows nothing, knows nothing.
516 | But he who knows he knows nothing knows something.
517 | And he who knows someone whose friend's wife's brother knows nothing,
518 | he knows something. Or something like that.
519 | %
520 | He who knows others is wise.
521 | He who knows himself is enlightened.
522 | -- Lao Tsu
523 | %
524 | He who knows that enough is enough will always have enough.
525 | -- Lao Tsu
526 | %
527 | He who knows, does not speak. He who speaks, does not know.
528 | -- Lao Tsu
529 | %
530 | ...He who laughs does not believe in what he laughs at, but neither
531 | does he hate it. Therefore, laughing at evil means not preparing oneself to
532 | combat it, and laughing at good means denying the power through which good is
533 | self-propagating.
534 | -- Umberto Eco, "The Name of the Rose"
535 | %
536 | Here is a test to find whether your mission on earth is finished:
537 | if you're alive, it isn't.
538 | %
539 | How can you prove whether at this moment we are sleeping, and all our
540 | thoughts are a dream; or whether we are awake, and talking to one another
541 | in the waking state?
542 | -- Plato
543 | %
544 | I am not afraid of tomorrow, for I have seen yesterday and I love today.
545 | -- William Allen White
546 | %
547 | I didn't believe in reincarnation in any of my other lives. I don't see why
548 | I should have to believe in it in this one.
549 | -- Strange de Jim
550 | %
551 | I do not know whether I was then a man dreaming I was a butterfly, or
552 | whether I am now a butterfly dreaming I am a man.
553 | -- Chuang-tzu
554 | %
555 | I do not seek the ignorant; the ignorant seek me -- I will instruct them.
556 | I ask nothing but sincerity. If they come out of habit, they become tiresome.
557 | -- I Ching
558 | %
559 | "I gained nothing at all from Supreme Enlightenment, and for that very
560 | reason it is called Supreme Enlightenment."
561 | -- Gotama Buddha
562 | %
563 | I hate dying.
564 | -- Dave Johnson
565 | %
566 | I have a simple philosophy:
567 |
568 | Fill what's empty.
569 | Empty what's full.
570 | Scratch where it itches.
571 | -- A. R. Longworth
572 | %
573 | I have often regretted my speech, never my silence.
574 | -- Publilius Syrus
575 | %
576 | I have seen the future and it is just like the present, only longer.
577 | -- Kehlog Albran, "The Profit"
578 | %
579 | I hope you're not pretending to be evil while secretly being good.
580 | That would be dishonest.
581 | %
582 | I just forgot my whole philosophy of life!!!
583 | %
584 | I know not how I came into this, shall I call it a dying life or a
585 | living death?
586 | -- St. Augustine
587 | %
588 | "I quite agree with you," said the Duchess; "and the moral of
589 | that is -- `Be what you would seem to be' -- or, if you'd like it put
590 | more simply -- `Never imagine yourself not to be otherwise than what it
591 | might appear to others that what you were or might have been was not
592 | otherwise than what you had been would have appeared to them to be
593 | otherwise.'"
594 | -- Lewis Carrol, "Alice in Wonderland"
595 | %
596 | If a guru falls in the forest with no one to hear him, was he really a
597 | guru at all?
598 | -- Strange de Jim, "The Metasexuals"
599 | %
600 | If a man has a strong faith he can indulge in the luxury of skepticism.
601 | -- Friedrich Nietzsche
602 | %
603 | If a man loses his reverence for any part of life, he will lose his
604 | reverence for all of life.
605 | -- Albert Schweitzer
606 | %
607 | If I had a formula for bypassing trouble, I would not pass it around.
608 | Trouble creates a capacity to handle it. I don't say embrace trouble; that's
609 | as bad as treating it as an enemy. But I do say meet it as a friend, for
610 | you'll see a lot of it and you had better be on speaking terms with it.
611 | -- Oliver Wendell Holmes, Jr.
612 | %
613 | If I had my life to live over, I'd try to make more mistakes next time. I
614 | would relax, I would limber up, I would be sillier than I have been this
615 | trip. I know of very few things I would take seriously. I would be crazier.
616 | I would climb more mountains, swim more rivers and watch more sunsets. I'd
617 | travel and see. I would have more actual troubles and fewer imaginary ones.
618 | You see, I am one of those people who lives prophylactically and sensibly
619 | and sanely, hour after hour, day after day. Oh, I have had my moments and,
620 | if I had it to do over again, I'd have more of them. In fact, I'd try to
621 | have nothing else. Just moments, one after another, instead of living so many
622 | years ahead each day. I have been one of those people who never go anywhere
623 | without a thermometer, a hotwater bottle, a gargle, a raincoat and a parachute.
624 | If I had it to do over again, I would go places and do things and travel
625 | lighter than I have. If I had my life to live over, I would start bare-footed
626 | earlier in the spring and stay that way later in the fall. I would play hooky
627 | more. I probably wouldn't make such good grades, but I'd learn more. I would
628 | ride on more merry-go-rounds. I'd pick more daisies.
629 | %
630 | If little green men land in your back yard, hide any little green women
631 | you've got in the house.
632 | -- Mike Harding, "The Armchair Anarchist's Almanac"
633 | %
634 | If men are not afraid to die,
635 | it is of no avail to threaten them with death.
636 |
637 | If men live in constant fear of dying,
638 | And if breaking the law means a man will be killed,
639 | Who will dare to break the law?
640 |
641 | There is always an official executioner.
642 | If you try to take his place,
643 | It is like trying to be a master carpenter and cutting wood.
644 | If you try to cut wood like a master carpenter,
645 | you will only hurt your hand.
646 | -- Tao Te Ching, "Lao Tsu, #74"
647 | %
648 | If something has not yet gone wrong then it would ultimately have been
649 | beneficial for it to go wrong.
650 | %
651 | If the master dies and the disciple grieves, the lives of both have
652 | been wasted.
653 | %
654 | If the path be beautiful, let us not ask where it leads.
655 | -- Anatole France
656 | %
657 | If there is a possibility of several things going wrong,
658 | the one that will cause the most damage will be the one to go wrong.
659 |
660 | If you perceive that there are four possible ways in which a procedure
661 | can go wrong, and circumvent these, then a fifth way will promptly develop.
662 | %
663 | If there is a sin against life, it consists perhaps not so much in despairing
664 | of life as in hoping for another life and in eluding the implacable grandeur
665 | of this life.
666 | -- Albert Camus
667 | %
668 | If we do not change our direction we are likely to end up where we are headed.
669 | %
670 | If we don't survive, we don't do anything else.
671 | -- John Sinclair
672 | %
673 | If you are not for yourself, who will be for you?
674 | If you are for yourself, then what are you?
675 | If not now, when?
676 | %
677 | If you can survive death, you can probably survive anything.
678 | %
679 | If you find a solution and become attached to it, the solution may become
680 | your next problem.
681 | %
682 | If you fool around with something long enough, it will eventually break.
683 | %
684 | If you have to hate, hate gently.
685 | %
686 | If you have to think twice about it, you're wrong.
687 | %
688 | If you keep anything long enough, you can throw it away.
689 | %
690 | If you live long enough, you'll see that every victory turns into a defeat.
691 | -- Simone de Beauvoir
692 | %
693 | If you only have a hammer, you tend to see every problem as a nail.
694 | -- Maslow
695 | %
696 | If you put it off long enough, it might go away.
697 | %
698 | If you refuse to accept anything but the best you very often get it.
699 | %
700 | If you wait long enough, it will go away... after having done its damage.
701 | If it was bad, it will be back.
702 | %
703 | If you want divine justice, die.
704 | -- Nick Seldon
705 | %
706 | If your aim in life is nothing, you can't miss.
707 | %
708 | If your happiness depends on what somebody else does, I guess you do
709 | have a problem.
710 | -- Richard Bach, "Illusions"
711 | %
712 | Illusion is the first of all pleasures.
713 | -- Voltaire
714 | %
715 | Immortality -- a fate worse than death.
716 | -- Edgar A. Shoaff
717 | %
718 | In dwelling, be close to the land.
719 | In meditation, delve deep into the heart.
720 | In dealing with others, be gentle and kind.
721 | In speech, be true.
722 | In work, be competent.
723 | In action, be careful of your timing.
724 | -- Lao Tsu
725 | %
726 | In order to discover who you are, first learn who everybody else is;
727 | you're what's left.
728 | %
729 | In order to live free and happily, you must sacrifice boredom.
730 | It is not always an easy sacrifice.
731 | %
732 | In spite of everything, I still believe that people are good at heart.
733 | -- Ann Frank
734 | %
735 | In the long run we are all dead.
736 | -- John Maynard Keynes
737 | %
738 | In the next world, you're on your own.
739 | %
740 | Indeed, the first noble truth of Buddhism, usually translated as
741 | `all life is suffering,' is more accurately rendered `life is filled
742 | with a sense of pervasive unsatisfactoriness.'
743 | -- M.D. Epstein
744 | %
745 | Instead of loving your enemies, treat your friends a little better.
746 | -- Edgar W. Howe
747 | %
748 | Intellect annuls Fate.
749 | So far as a man thinks, he is free.
750 | -- Ralph Waldo Emerson
751 | %
752 | It does not do to leave a live dragon out of your calculations.
753 | %
754 | It is easier for a camel to pass through the eye of a needle if it is
755 | lightly greased.
756 | -- Kehlog Albran, "The Profit"
757 | %
758 | It is Fortune, not Wisdom, that rules man's life.
759 | %
760 | It is not doing the thing we like to do, but liking the thing we have to do,
761 | that makes life blessed.
762 | -- Goethe
763 | %
764 | It is only by risking our persons from one hour to another that we live
765 | at all. And often enough our faith beforehand in an uncertified result
766 | is the only thing that makes the result come true.
767 | -- William James
768 | %
769 | It is only with the heart one can see clearly; what is essential is
770 | invisible to the eye.
771 | -- The Fox, 'The Little Prince"
772 | %
773 | It is said that the lonely eagle flies to the mountain peaks while the lowly
774 | ant crawls the ground, but cannot the soul of the ant soar as high as the eagle?
775 | %
776 | It is so stupid of modern civilisation to have given up believing in the
777 | devil when he is the only explanation of it.
778 | -- Ronald Knox, "Let Dons Delight"
779 | %
780 | It is through symbols that man consciously or unconsciously lives, works
781 | and has his being.
782 | -- Thomas Carlyle
783 | %
784 | It will be advantageous to cross the great stream ... the Dragon is on
785 | the wing in the Sky ... the Great Man rouses himself to his Work.
786 | %
787 | It's easier to take it apart than to put it back together.
788 | -- Washlesky
789 | %
790 | It's hard to drive at the limit, but it's harder to know where the limits are.
791 | -- Stirling Moss
792 | %
793 | It's not reality that's important, but how you perceive things.
794 | %
795 | "It's today!" said Piglet.
796 | "My favorite day," said Pooh.
797 | %
798 | It's very inconvenient to be mortal -- you never know when everything may
799 | suddenly stop happening.
800 | %
801 | Joshu: What is the true Way?
802 | Nansen: Every way is the true Way.
803 | J: Can I study it?
804 | N: The more you study, the further from the Way.
805 | J: If I don't study it, how can I know it?
806 | N: The Way does not belong to things seen: nor to things unseen.
807 | It does not belong to things known: nor to things unknown. Do
808 | not seek it, study it, or name it. To find yourself on it, open
809 | yourself as wide as the sky.
810 | %
811 | Just remember, wherever you go, there you are.
812 | -- Buckaroo Bonzai
813 | %
814 | Kindness is the beginning of cruelty.
815 | -- Muad'dib [Frank Herbert, "Dune"]
816 | %
817 | Let us not look back in anger or forward in fear, but around us in awareness.
818 | -- James Thurber
819 | %
820 | Life can be so tragic -- you're here today and here tomorrow.
821 | %
822 | Life exists for no known purpose.
823 | %
824 | Life is a grand adventure -- or it is nothing.
825 | -- Helen Keller
826 | %
827 | Life is knowing how far to go without crossing the line.
828 | %
829 | Life is like a 10 speed bicycle. Most of us have gears we never use.
830 | -- C. Schultz
831 | %
832 | Life is like a sewer. What you get out of it depends on what you put into it.
833 | -- Tom Lehrer
834 | %
835 | Life is the childhood of our immortality.
836 | -- Goethe
837 | %
838 | Life is the living you do, Death is the living you don't do.
839 | -- Joseph Pintauro
840 | %
841 | Life is the urge to ecstasy.
842 | %
843 | Life may have no meaning, or, even worse, it may have a meaning of which
844 | you disapprove.
845 | %
846 | Life only demands from you the strength you possess.
847 | Only one feat is possible -- not to have run away.
848 | -- Dag Hammarskjold
849 | %
850 | Life sucks, but death doesn't put out at all.
851 | -- Thomas J. Kopp
852 | %
853 | Like, if I'm not for me, then fer shure, like who will be? And if, y'know,
854 | if I'm not like fer anyone else, then hey, I mean, what am I? And if not
855 | now, like I dunno, maybe like when? And if not Who, then I dunno, maybe
856 | like the Rolling Stones?
857 | -- Rich Rosen (Rabbi Valiel's paraphrase of famous quote
858 | attributed to Rabbi Hillel.)
859 | %
860 | Live never to be ashamed if anything you do or say is
861 | published around the world -- even if what is published is not true.
862 | -- Messiah's Handbook : Reminders for the Advanced Soul
863 | %
864 | Living in the complex world of the future is somewhat like having bees
865 | live in your head. But, there they are.
866 | %
867 | Loneliness is a terrible price to pay for independence.
868 | %
869 | Long were the days of pain I have spent within its walls, and
870 | long were the nights of aloneness; and who can depart from his
871 | pain and his aloneness without regret?
872 | -- Kahlil Gibran, "The Prophet"
873 | %
874 | Man's reach must exceed his grasp, for why else the heavens?
875 | %
876 | [Maturity consists in the discovery that] there comes a critical moment
877 | where everything is reversed, after which the point becomes to understand
878 | more and more that there is something which cannot be understood.
879 | -- S. Kierkegaard
880 | %
881 | Mohandas K. Gandhi often changed his mind publicly. An aide once asked him
882 | how he could so freely contradict this week what he had said just last week.
883 | The great man replied that it was because this week he knew better.
884 | %
885 | Most of what I really need to know about how to live, and what to do,
886 | and how to be, I learned in kindergarten. Wisdom was not at the top of the
887 | graduate school mountain but there in the sandbox at nursery school.
888 | These are the things I learned: Share everything. Play fair. Don't
889 | hit people. Put things back where you found them. Clean up your own mess.
890 | Don't take things that aren't yours. Say you're sorry when you hurt someone.
891 | Wash your hands before you eat. Flush. Warm cookies and cold milk are good
892 | for you. Live a balanced life. Learn some and think some and draw and paint
893 | and sing and dance and play and work some every day.
894 | Take a nap every afternoon. When you go out into the world, watch for
895 | traffic, hold hands, and stick together. Be aware of wonder. Remember the
896 | little seed in the plastic cup. The roots go down and the plant goes up and
897 | nobody really knows how or why, but we are all like that. Goldfish and
898 | hamsters and white mice and even the little seed in the plastic cup -- they all
899 | die. So do we.
900 | And then remember the book about Dick and Jane and the first word you
901 | learned, the biggest word of all: LOOK. Everything you need to know is in
902 | there somewhere. The Golden Rule and love and basic sanitation. Ecology and
903 | politics and sane living.
904 | Think of what a better world it would be if we all -- the whole world
905 | -- had cookies and milk about 3 o'clock every afternoon and then lay down with
906 | our blankets for a nap. Or if we had a basic policy in our nation and other
907 | nations to always put things back where we found them and cleaned up our own
908 | messes. And it is still true, no matter how old you are, when you go out into
909 | the world it is best to hold hands and stick together.
910 | -- Robert Fulghum, "All I ever really needed to know I learned
911 | in kindergarten"
912 | %
913 | Murphy was an optimist.
914 | %
915 | Murphy's Law is recursive. Washing your car to make it rain doesn't work.
916 | %
917 | Music in the soul can be heard by the universe.
918 | -- Lao Tsu
919 | %
920 | My religion consists of a humble admiration of the illimitable superior
921 | spirit who reveals himself in the slight details we are able to perceive
922 | with our frail and feeble mind.
923 | -- Albert Einstein
924 | %
925 | My theology, briefly, is that the universe was dictated but not signed.
926 | -- Christopher Morley
927 | %
928 | Nasrudin called at a large house to collect for charity. The servant said
929 | "My master is out." Nasrudin replied, "Tell your master that next time he
930 | goes out, he should not leave his face at the window. Someone might steal it."
931 | %
932 | Nasrudin returned to his village from the imperial capital, and the villagers
933 | gathered around to hear what had passed. "At this time," said Nasrudin, "I
934 | only want to say that the King spoke to me." All the villagers but the
935 | stupidest ran off to spread the wonderful news. The remaining villager
936 | asked, "What did the King say to you?" "What he said -- and quite distinctly,
937 | for everyone to hear -- was 'Get out of my way!'" The simpleton was overjoyed;
938 | he had heard words actually spoken by the King, and seen the very man they
939 | were spoken to.
940 | %
941 | Nasrudin walked into a shop one day, and the owner came forward to serve
942 | him. Nasrudin said, "First things first. Did you see me walk into your
943 | shop?"
944 | "Of course."
945 | "Have you ever seen me before?"
946 | "Never."
947 | "Then how do you know it was me?"
948 | %
949 | Nasrudin walked into a teahouse and declaimed, "The moon is more useful
950 | than the sun."
951 | "Why?", he was asked.
952 | "Because at night we need the light more."
953 | %
954 | Nasrudin was carrying home a piece of liver and the recipe for liver pie.
955 | Suddenly a bird of prey swooped down and snatched the piece of meat from his
956 | hand. As the bird flew off, Nasrudin called after it, "Foolish bird! You
957 | have the liver, but what can you do with it without the recipe?"
958 | %
959 | Ninety percent of everything is crap.
960 | -- Theodore Sturgeon
961 | %
962 | Ninety percent of the time things turn out worse than you thought they would.
963 | The other ten percent of the time you had no right to expect that much.
964 | -- Augustine
965 | %
966 | No man is an Iland, intire of it selfe; every man is a peece of the
967 | Continent, a part of the maine; if a Clod bee washed away by the Sea,
968 | Europe is the lesse, as well as if a Promontorie were, as well as if
969 | a Mannor of thy friends or of thine owne were; any mans death diminishes
970 | me, because I am involved in Mankinde; And therefore never send to know
971 | for whom the bell tolls; It tolls for thee.
972 | -- John Donne, "No Man is an Iland"
973 | %
974 | No matter where I go, the place is always called "here".
975 | %
976 | No use getting too involved in life -- you're only here for a limited time.
977 | %
978 | Nobody ever ruined their eyesight by looking at the bright side of something.
979 | %
980 | Nonsense and beauty have close connections.
981 | -- E.M. Forster
982 | %
983 | Normal times may possibly be over forever.
984 | %
985 | Not every question deserves an answer.
986 | %
987 | Nothing in life is to be feared. It is only to be understood.
988 | %
989 | Nothing is as simple as it seems at first
990 | Or as hopeless as it seems in the middle
991 | Or as finished as it seems in the end.
992 | %
993 | Nothing is but what is not.
994 | %
995 | Nothing is ever a total loss; it can always serve as a bad example.
996 | %
997 | Nothing is so firmly believed as that which we least know.
998 | -- Michel de Montaigne
999 | %
1000 | Nothing matters very much, and few things matter at all.
1001 | -- Arthur Balfour
1002 | %
1003 | Of all men's miseries, the bitterest is this:
1004 | to know so much and have control over nothing.
1005 | -- Herodotus
1006 | %
1007 | Once the toothpaste is out of the tube, it's hard to get it back in.
1008 | -- H.R. Haldeman
1009 | %
1010 | Once there lived a village of creatures along the bottom of a great
1011 | crystal river. Each creature in its own manner clung tightly to the twigs
1012 | and rocks of the river bottom, for clinging was their way of life, and
1013 | resisting the current what each had learned from birth. But one creature
1014 | said at last, "I trust that the current knows where it is going. I shall
1015 | let go, and let it take me where it will. Clinging, I shall die of boredom."
1016 | The other creatures laughed and said, "Fool! Let go, and that current
1017 | you worship will throw you tumbled and smashed across the rocks, and you will
1018 | die quicker than boredom!"
1019 | But the one heeded them not, and taking a breath did let go, and at
1020 | once was tumbled and smashed by the current across the rocks. Yet, in time,
1021 | as the creature refused to cling again, the current lifted him free from the
1022 | bottom, and he was bruised and hurt no more.
1023 | And the creatures downstream, to whom he was a stranger, cried, "See
1024 | a miracle! A creature like ourselves, yet he flies! See the Messiah, come
1025 | to save us all!" And the one carried in the current said, "I am no more
1026 | Messiah than you. The river delight to lift us free, if only we dare let go.
1027 | Our true work is this voyage, this adventure.
1028 | But they cried the more, "Saviour!" all the while clinging to the
1029 | rocks, making legends of a Saviour.
1030 | -- Richard Bach
1031 | %
1032 | Once you've tried to change the world you find it's a whole bunch easier
1033 | to change your mind.
1034 | %
1035 | One day it was announced that the young monk Kyogen had reached
1036 | an enlightened state. Much impressed by this news, several of his peers
1037 | went to speak with him.
1038 | "We have heard that you are enlightened. Is this true?" his fellow
1039 | students inquired.
1040 | "It is", Kyogen answered.
1041 | "Tell us", said a friend, "how do you feel?"
1042 | "As miserable as ever", replied the enlightened Kyogen.
1043 | %
1044 | One day the King decided that he would force all his subjects to tell the
1045 | truth. A gallows was erected in front of the city gates. A herald announced,
1046 | "Whoever would enter the city must first answer the truth to a question
1047 | which will be put to him." Nasrudin was first in line. The captain of the
1048 | guard asked him, "Where are you going? Tell the truth -- the alternative
1049 | is death by hanging."
1050 | "I am going," said Nasrudin, "to be hanged on that gallows."
1051 | "I don't believe you."
1052 | "Very well, if I have told a lie, then hang me!"
1053 | "But that would make it the truth!"
1054 | "Exactly," said Nasrudin, "your truth."
1055 | %
1056 | One learns to itch where one can scratch.
1057 | -- Ernest Bramah
1058 | %
1059 | One meets his destiny often on the road he takes to avoid it.
1060 | %
1061 | One monk said to the other, "The fish has flopped out of the net! How will it
1062 | live?" The other said, "When you have gotten out of the net, I'll tell you."
1063 | %
1064 | Only that in you which is me can hear what I'm saying.
1065 | -- Baba Ram Dass
1066 | %
1067 | Only those who leisurely approach that which the masses are busy about
1068 | can be busy about that which the masses take leisurely.
1069 | -- Lao Tsu
1070 | %
1071 | Paradise is exactly like where you are right now ... only much, much better.
1072 | -- Laurie Anderson
1073 | %
1074 | Perfection is reached, not when there is no longer anything to add, but
1075 | when there is no longer anything to take away.
1076 | -- Antoine de Saint-Exupery
1077 | %
1078 | Perhaps the biggest disappointments were the ones you expected anyway.
1079 | %
1080 | Philosophy will clip an angel's wings.
1081 | -- John Keats
1082 | %
1083 | Push where it gives and scratch where it itches.
1084 | %
1085 | Reality always seems harsher in the early morning.
1086 | %
1087 | Reality does not exist -- yet.
1088 | %
1089 | Reality is bad enough, why should I tell the truth?
1090 | -- Patrick Sky
1091 | %
1092 | Reality is for people who lack imagination.
1093 | %
1094 | Reality is just a convenient measure of complexity.
1095 | -- Alvy Ray Smith
1096 | %
1097 | Reality is just a crutch for people who can't handle science fiction.
1098 | %
1099 | Reality is nothing but a collective hunch.
1100 | -- Lily Tomlin
1101 | %
1102 | "Reality is that which, when you stop believing in it, doesn't go away".
1103 | -- Philip K. Dick
1104 | %
1105 | Remember, Grasshopper, falling down 1000 stairs begins by tripping over
1106 | the first one.
1107 | -- Confusion
1108 | %
1109 | Rule of Life #1 -- Never get separated from your luggage.
1110 | %
1111 | Seeing is believing. You wouldn't have seen it if you hadn't believed it.
1112 | %
1113 | Since everything in life is but an experience perfect in being what it is,
1114 | having nothing to do with good or bad, acceptance or rejection, one may well
1115 | burst out in laughter.
1116 | -- Long Chen Pa
1117 | %
1118 | So little time, so little to do.
1119 | -- Oscar Levant
1120 | %
1121 | Sometimes even to live is an act of courage.
1122 | -- Seneca
1123 | %
1124 | Sometimes you get an almost irresistible urge to go on living.
1125 | %
1126 | Standards are different for all things, so the standard set by man is by
1127 | no means the only 'certain' standard. If you mistake what is relative for
1128 | something certain, you have strayed far from the ultimate truth.
1129 | -- Chuang Tzu
1130 | %
1131 | Suffering alone exists, none who suffer;
1132 | The deed there is, but no doer thereof;
1133 | Nirvana is, but no one is seeking it;
1134 | The Path there is, but none who travel it.
1135 | -- "Buddhist Symbolism", Symbols and Values
1136 | %
1137 | Superstition, idolatry, and hypocrisy have ample wages, but truth goes
1138 | a-begging.
1139 | -- Martin Luther
1140 | %
1141 | Take your dying with some seriousness, however. Laughing on the way to
1142 | your execution is not generally understood by less advanced life forms,
1143 | and they'll call you crazy.
1144 | -- "Messiah's Handbook: Reminders for the Advanced Soul"
1145 | %
1146 | That that is is that that is not is not.
1147 | %
1148 | That, that is, is.
1149 | That, that is not, is not.
1150 | That, that is, is not that, that is not.
1151 | That, that is not, is not that, that is.
1152 | %
1153 | The absurd is the essential concept and the first truth.
1154 | -- A. Camus
1155 | %
1156 | The best you get is an even break.
1157 | -- Franklin Adams
1158 | %
1159 | "The chain which can be yanked is not the eternal chain."
1160 | -- G. Fitch
1161 | %
1162 | The chief cause of problems is solutions.
1163 | -- Eric Sevareid
1164 | %
1165 | The chief danger in life is that you may take too many precautions.
1166 | -- Alfred Adler
1167 | %
1168 | The days are all empty and the nights are unreal.
1169 | %
1170 | The door is the key.
1171 | %
1172 | The eye is a menace to clear sight, the ear is a menace to subtle hearing,
1173 | the mind is a menace to wisdom, every organ of the senses is a menace to its
1174 | own capacity. ... Fuss, the god of the Southern Ocean, and Fret, the god
1175 | of the Northern Ocean, happened once to meet in the realm of Chaos, the god
1176 | of the center. Chaos treated them very handsomely and they discussed together
1177 | what they could do to repay his kindness. They had noticed that, whereas
1178 | everyone else had seven apertures, for sight, hearing, eating, breathing and
1179 | so on, Chaos had none. So they decided to make the experiment of boring holes
1180 | in him. Every day they bored a hole, and on the seventh day, Chaos died.
1181 | -- Chuang Tzu
1182 | %
1183 | The farther you go, the less you know.
1184 | -- Lao Tsu, "Tao Te Ching"
1185 | %
1186 | The final delusion is the belief that one has lost all delusions.
1187 | -- Maurice Chapelain, "Main courante"
1188 | %
1189 | The first requisite for immortality is death.
1190 | -- Stanislaw Lem
1191 | %
1192 | The greatest griefs are those we cause ourselves.
1193 | -- Sophocles
1194 | %
1195 | The longest part of the journey is said to be the passing of the gate.
1196 | -- Marcus Terentius Varro
1197 | %
1198 | The major sin is the sin of being born.
1199 | -- Samuel Beckett
1200 | %
1201 | The mark of your ignorance is the depth of your belief in injustice
1202 | and tragedy. What the caterpillar calls the end of the world, the
1203 | master calls a butterfly.
1204 | -- Messiah's Handbook : Reminders for the Advanced Soul
1205 | %
1206 | The more laws and order are made prominent, the more thieves and
1207 | robbers there will be.
1208 | -- Lao Tsu
1209 | %
1210 | The more you complain, the longer God lets you live.
1211 | %
1212 | The moss on the tree does not fear the talons of the hawk.
1213 | %
1214 | The most costly of all follies is to believe passionately in the palpably
1215 | not true. It is the chief occupation of mankind.
1216 | -- H.L. Mencken
1217 | %
1218 | The only difference between a rut and a grave is their dimensions.
1219 | %
1220 | The only happiness lies in reason; all the rest of the world is dismal.
1221 | The highest reason, however, I see in the work of the artist, and he may
1222 | experience it as such. Happiness lies in the swiftness of feeling and
1223 | thinking: all the rest of the world is slow, gradual and stupid. Whoever
1224 | could feel the course of a light ray would be very happy, for it is very
1225 | swift. Thinking of oneself gives little happiness. If, however, one feels
1226 | much happiness in this, it is because at bottom one is not thinking of
1227 | oneself but of one's ideal. This is far, and only the swift shall reach
1228 | it and are delighted.
1229 | -- Nietzsche
1230 | %
1231 | The optimist thinks that this is the best of all possible worlds,
1232 | and the pessimist knows it.
1233 | -- J. Robert Oppenheimer, "Bulletin of Atomic Scientists"
1234 |
1235 | Yet creeds mean very little, Coth answered the dark god, still speaking
1236 | almost gently. The optimist proclaims that we live in the best of all
1237 | possible worlds; and the pessimist fears this is true.
1238 | -- James Cabell, "The Silver Stallion"
1239 | %
1240 | The Poems, all three hundred of them, may be summed up in one of their phrases:
1241 | "Let our thoughts be correct".
1242 | -- Confucius
1243 | %
1244 | The price of success in philosophy is triviality.
1245 | -- C. Glymour.
1246 | %
1247 | The questions remain the same. The answers are eternally variable.
1248 | %
1249 | The race is not always to the swift, nor the battle to the strong, but
1250 | that's the way to bet.
1251 | -- Damon Runyon
1252 | %
1253 | The root of all superstition is that men observe when a thing hits,
1254 | but not when it misses.
1255 | -- Francis Bacon
1256 | %
1257 | The savior becomes the victim.
1258 | %
1259 | The soul would have no rainbow had the eyes no tears.
1260 | %
1261 | The state of innocence contains the germs of all future sin.
1262 | -- Alexandre Arnoux, "Etudes et caprices"
1263 | %
1264 | The true way goes over a rope which is not stretched at any great height
1265 | but just above the ground. It seems more designed to make people stumble
1266 | than to be walked upon.
1267 | -- Franz Kafka
1268 | %
1269 | The truth is rarely pure, and never simple.
1270 | -- Oscar Wilde
1271 | %
1272 | The truth is what is; what should be is a dirty lie.
1273 | -- Lenny Bruce
1274 | %
1275 | The truth of a thing is the feel of it, not the think of it.
1276 | -- Stanley Kubrick
1277 | %
1278 | The truth you speak has no past and no future. It is, and that's all it
1279 | needs to be.
1280 | %
1281 | The world is your exercise-book, the pages on which you do your sums.
1282 | It is not reality, although you can express reality there if you wish.
1283 | You are also free to write nonsense, or lies, or to tear the pages.
1284 | -- Messiah's Handbook : Reminders for the Advanced Soul
1285 | %
1286 | There are no accidents whatsoever in the universe.
1287 | -- Baba Ram Dass
1288 | %
1289 | There are no winners in life, only survivors.
1290 | %
1291 | There are ten or twenty basic truths, and life is the process of
1292 | discovering them over and over and over.
1293 | -- David Nichols
1294 | %
1295 | There is more to life than increasing its speed.
1296 | -- Mahatma Gandhi
1297 | %
1298 | There is no comfort without pain; thus we define salvation through suffering.
1299 | -- Cato
1300 | %
1301 | There is no cure for birth and death other than to enjoy the interval.
1302 | -- George Santayana
1303 | %
1304 | There is no sin but ignorance.
1305 | -- Christopher Marlowe
1306 | %
1307 | There is nothing which cannot be answered by means of my doctrine," said
1308 | a monk, coming into a teahouse where Nasrudin sat.
1309 | "And yet just a short time ago, I was challenged by a scholar with
1310 | an unanswerable question," said Nasrudin.
1311 | "I could have answered it if I had been there."
1312 | "Very well. He asked, 'Why are you breaking into my house in
1313 | the middle of the night?'"
1314 | %
1315 | There's only one everything.
1316 | %
1317 | To get something clean, one has to get something dirty.
1318 | To get something dirty, one does not have to get anything clean.
1319 | %
1320 | To give happiness is to deserve happiness.
1321 | %
1322 | To give of yourself, you must first know yourself.
1323 | %
1324 | To have died once is enough.
1325 | -- Publius Vergilius Maro (Virgil)
1326 | %
1327 | To lead people, you must follow behind.
1328 | -- Lao Tsu
1329 | %
1330 | Truth has no special time of its own. Its hour is now -- always.
1331 | -- Albert Schweitzer
1332 | %
1333 | Truth is hard to find and harder to obscure.
1334 | %
1335 | Truth never comes into the world but like a bastard, to the ignominy
1336 | of him that brought her birth.
1337 | -- Milton
1338 | %
1339 | Two men came before Nasrudin when he was magistrate. The first man said,
1340 | "This man has bitten my ear -- I demand compensation." The second man said,
1341 | "He bit it himself." Nasrudin withdrew to his chambers, and spent an hour
1342 | trying to bite his own ear. He succeeded only in falling over and bruising
1343 | his forehead. Returning to the courtroom, Nasrudin pronounced, "Examine the
1344 | man whose ear was bitten. If his forehead is bruised, he did it himself and
1345 | the case is dismissed. If his forehead is not bruised, the other man did it
1346 | and must pay three silver pieces."
1347 | %
1348 | Two men were sitting over coffee, contemplating the nature of things,
1349 | with all due respect for their breakfast. "I wonder why it is that
1350 | toast always falls on the buttered side," said one.
1351 | "Tell me," replied his friend, "why you say such a thing. Look
1352 | at this." And he dropped his toast on the floor, where it landed on the
1353 | dry side.
1354 | "So, what have you to say for your theory now?"
1355 | "What am I to say? You obviously buttered the wrong side."
1356 | %
1357 | Waste not fresh tears over old griefs.
1358 | -- Euripides
1359 | %
1360 | We can embody the truth, but we cannot know it.
1361 | -- Yates
1362 | %
1363 | We have nowhere else to go... this is all we have.
1364 | -- Margaret Mead
1365 | %
1366 | We have only two things to worry about: That things will never get
1367 | back to normal, and that they already have.
1368 | %
1369 | We have reason to be afraid. This is a terrible place.
1370 | -- John Berryman
1371 | %
1372 | We rarely find anyone who can say he has lived a happy life, and who,
1373 | content with his life, can retire from the world like a satisfied guest.
1374 | -- Quintus Horatius Flaccus (Horace)
1375 | %
1376 | We're all in this alone.
1377 | -- Lily Tomlin
1378 | %
1379 | We're mortal -- which is to say, we're ignorant, stupid, and sinful --
1380 | but those are only handicaps. Our pride is that nevertheless, now and
1381 | then, we do our best. A few times we succeed. What more dare we ask for?
1382 | -- Ensign Flandry
1383 | %
1384 | "We're not talking about the same thing," he said. "For you the world is
1385 | weird because if you're not bored with it you're at odds with it. For me
1386 | the world is weird because it is stupendous, awesome, mysterious,
1387 | unfathomable; my interest has been to convince you that you must accept
1388 | responsibility for being here, in this marvelous world, in this marvelous
1389 | desert, in this marvelous time. I wanted to convince you that you must
1390 | learn to make every act count, since you are going to be here for only a
1391 | short while, in fact, too short for witnessing all the marvels of it."
1392 | -- Don Juan
1393 | %
1394 | Well, he thought, since neither Aristotelian Logic nor the disciplines
1395 | of Science seemed to offer much hope, it's time to go beyond them...
1396 | Drawing a few deep even breaths, he entered a mental state practiced
1397 | only by Masters of the Universal Way of Zen. In it his mind floated freely,
1398 | able to rummage at will among the bits and pieces of data he had absorbed,
1399 | undistracted by any outside disturbances. Logical structures no longer
1400 | inhibited him. Pre-conceptions, prejudices, ordinary human standards vanished.
1401 | All things, those previously trivial as well as those once thought important,
1402 | became absolutely equal by acquiring an absolute value, revealing relationships
1403 | not evident to ordinary vision. Like beads strung on a string of their own
1404 | meaning, each thing pointed to its own common ground of existence, shared by
1405 | all. Finally, each began to melt into each, staying itself while becoming
1406 | all others. And Mind no longer contemplated Problem, but became Problem,
1407 | destroying Subject-Object by becoming them.
1408 | Time passed, unheeded.
1409 | Eventually, there was a tentative stirring, then a decisive one, and
1410 | Nakamura arose, a smile on his face and the light of laughter in his eyes.
1411 | -- Wayfarer
1412 | %
1413 | Well, you know, no matter where you go, there you are.
1414 | -- Buckaroo Banzai
1415 | %
1416 | "Well," Brahma said, "even after ten thousand explanations, a fool is no
1417 | wiser, but an intelligent man requires only two thousand five hundred."
1418 | -- The Mahabharata.
1419 | %
1420 | What does not destroy me, makes me stronger.
1421 | -- Nietzsche
1422 | %
1423 | What makes the universe so hard to comprehend is that there's nothing
1424 | to compare it with.
1425 | %
1426 | What sane person could live in this world and not be crazy?
1427 | -- Ursula K. LeGuin
1428 | %
1429 | What we Are is God's gift to us.
1430 | What we Become is our gift to God.
1431 | %
1432 | Whatever occurs from love is always beyond good and evil.
1433 | -- Friedrich Nietzsche
1434 | %
1435 | Whatever you do will be insignificant, but it is very important that you do it.
1436 | -- Gandhi
1437 | %
1438 | When it's dark enough you can see the stars.
1439 | -- Ralph Waldo Emerson,
1440 | %
1441 | When the speaker and he to whom he is speaks do not understand, that is
1442 | metaphysics.
1443 | -- Voltaire
1444 | %
1445 | When the wind is great, bow before it;
1446 | when the wind is heavy, yield to it.
1447 | %
1448 | When you are young, you enjoy a sustained illusion that sooner or later
1449 | something marvelous is going to happen, that you are going to transcend
1450 | your parents' limitations... At the same time, you feel sure that in all
1451 | the wilderness of possibility; in all the forests of opinion, there is a
1452 | vital something that can be known -- known and grasped. That we will
1453 | eventually know it, and convert the whole mystery into a coherent
1454 | narrative. So that then one's true life -- the point of everything --
1455 | will emerge from the mist into a pure light, into total comprehension.
1456 | But it isn't like that at all. But if it isn't, where did the idea come
1457 | from, to torture and unsettle us?
1458 | -- Brian Aldiss, "Helliconia Summer"
1459 | %
1460 | When you die, you lose a very important part of your life.
1461 | -- Brooke Shields
1462 | %
1463 | Who does not trust enough will not be trusted.
1464 | -- Lao Tsu
1465 | %
1466 | Wisdom is knowing what to do with what you know.
1467 | -- J. Winter Smith
1468 | %
1469 | Wisdom is rarely found on the best-seller list.
1470 | %
1471 | [Wisdom] is a tree of life to those laying
1472 | hold of her, making happy each one holding her fast.
1473 | -- Proverbs 3:18, NSV
1474 | %
1475 | With listening comes wisdom, with speaking repentance.
1476 | %
1477 | Wonder is the feeling of a philosopher, and philosophy begins in wonder.
1478 | -- Socrates, quoting Plato
1479 | [Huh? That's like Johnson quoting Boswell]
1480 | %
1481 | Work Hard.
1482 | Rock Hard.
1483 | Eat Hard.
1484 | Sleep Hard.
1485 | Grow Big.
1486 | Wear Glasses If You Need 'Em.
1487 | -- The Webb Wilder Credo
1488 | %
1489 | Yes, but which self do you want to be?
1490 | %
1491 | You are never given a wish without also being given the
1492 | power to make it true. You may have to work for it, however.
1493 | -- R. Bach, "Messiah's Handbook : Reminders for
1494 | the Advanced Soul"
1495 | %
1496 | You can always pick up your needle and move to another groove.
1497 | -- Tim Leary
1498 | %
1499 | You can get *anywhere* in ten minutes if you drive fast enough.
1500 | %
1501 | You can never tell which way the train went by looking at the tracks.
1502 | %
1503 | You can no more win a war than you can win an earthquake.
1504 | -- Jeannette Rankin
1505 | %
1506 | You can observe a lot just by watching.
1507 | -- Yogi Berra
1508 | %
1509 | You can only live once, but if you do it right, once is enough.
1510 | %
1511 | You can't get there from here.
1512 | %
1513 | You can't mend a wristwatch while falling from an airplane.
1514 | %
1515 | You can't push on a string.
1516 | %
1517 | You can't run away forever,
1518 | But there's nothing wrong with getting a good head start.
1519 | -- Jim Steinman, "Rock and Roll Dreams Come Through"
1520 | %
1521 | "You can't survive by sucking the juice from a wet mitten."
1522 | -- Charles Schulz, "Things I've Had to Learn Over and
1523 | Over and Over"
1524 | %
1525 | You can't take it with you -- especially when crossing a state line.
1526 | %
1527 | You climb to reach the summit, but once there, discover that all roads
1528 | lead down.
1529 | -- Stanislaw Lem, "The Cyberiad"
1530 | %
1531 | You have all eternity to be cautious in when you're dead.
1532 | -- Lois Platford
1533 | %
1534 | You have to run as fast as you can just to stay where you are.
1535 | If you want to get anywhere, you'll have to run much faster.
1536 | -- Lewis Carroll
1537 | %
1538 | "You mean, if you allow the master to be uncivil, to treat you
1539 | any old way he likes, and to insult your dignity, then he may deem you
1540 | fit to hear his view of things?"
1541 | "Quite the contrary. You must defend your integrity, assuming
1542 | you have integrity to defend. But you must defend it nobly, not by
1543 | imitating his own low behavior. If you are gentle where he is rough,
1544 | if you are polite where he is uncouth, then he will recognize you as
1545 | potentially worthy. If he does not, then he is not a master, after all,
1546 | and you may feel free to kick his ass."
1547 | -- Tom Robbins, "Jitterbug Perfume"
1548 | %
1549 | You will always find something in the last place you look.
1550 | %
1551 | "You would do well not to imagine profundity," he said. "Anything that seems
1552 | of momentous occasion should be dwelt upon as though it were of slight note.
1553 | Conversely, trivialities must be attended to with the greatest of care.
1554 | Because death is momentous, give it no thought; because victory is important,
1555 | give it no thought; because the method of achievement and discovery is less
1556 | momentous than the effect, dwell always upon the method. You will strengthen
1557 | yourself in this way."
1558 | -- Jessica Salmonson, "The Swordswoman"
1559 | %
1560 | Your happiness is intertwined with your outlook on life.
1561 | %
1562 | Your mind understands what you have been taught; your heart, what is true.
1563 | %
1564 | Your only obligation in any lifetime is to be true to yourself. Being
1565 | true to anyone else or anything else is not only impossible, but the
1566 | mark of a fake messiah. The simplest questions are the most profound.
1567 | Where were you born? Where is your home? Where are you going? What
1568 | are you doing? Think about these once in awhile and watch your answers
1569 | change.
1570 | -- Messiah's Handbook : Reminders for the Advanced Soul
1571 | %
1572 | Your picture of the world often changes just before you get it into focus.
1573 | %
1574 | Your wig steers the gig.
1575 | -- Lord Buckley
1576 | %
1577 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cpp-networking
2 | Projects from my C++ networking tutorials.
3 |
4 | ## Barebones Server
5 | Basic C++ barebones TCP server. You can use the client or PuTTY to connect to the client. Compiles using Visual C++.
6 |
7 | ## Barebones Client
8 | Basic C++ barebones TCP client. Compiles using Visual C++.
9 |
10 | ## Multiple Clients Barebones Server
11 | Basic C++ barebones multiple TCP clients server. Doesn't use threading! Compiles using Visual C++.
12 |
13 | ## Multiple Clients Barebones Server UDP
14 | Basic C++ barebones multiple UDP clients server. Doesn't use threading! Compiles using Visual C++.
15 |
16 | ## QOTD Server
17 | Quote of the day server written in C++. Uses UDP. Compiles using Visual C++.
18 |
19 | ## UDP Client Server Basic
20 | Basic UDP client written in C++. Compiles using Visual C++.
21 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Client/UDP_Client.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDP_Client", "UDP_Client\UDP_Client.vcxproj", "{5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Debug|x64.ActiveCfg = Debug|x64
17 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Debug|x64.Build.0 = Debug|x64
18 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Debug|x86.ActiveCfg = Debug|Win32
19 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Debug|x86.Build.0 = Debug|Win32
20 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Release|x64.ActiveCfg = Release|x64
21 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Release|x64.Build.0 = Release|x64
22 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Release|x86.ActiveCfg = Release|Win32
23 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Client/UDP_Client/UDP_Client.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {5CDDA05C-C239-4EFE-81C0-7B6E8AF77718}
23 | Win32Proj
24 | UDP_Client
25 | 10.0
26 |
27 |
28 |
29 | Application
30 | true
31 | v142
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v142
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v142
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v142
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
91 | true
92 |
93 |
94 | Console
95 | true
96 |
97 |
98 |
99 |
100 |
101 |
102 | Level3
103 | Disabled
104 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
105 | true
106 |
107 |
108 | Console
109 | true
110 |
111 |
112 |
113 |
114 | Level3
115 |
116 |
117 | MaxSpeed
118 | true
119 | true
120 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
121 | true
122 |
123 |
124 | Console
125 | true
126 | true
127 | true
128 |
129 |
130 |
131 |
132 | Level3
133 |
134 |
135 | MaxSpeed
136 | true
137 | true
138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
139 | true
140 |
141 |
142 | Console
143 | true
144 | true
145 | true
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Client/UDP_Client/UDP_Client.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Client/UDP_Client/main.cpp:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Name : Example UDP Client
3 | Author : Sloan Kelly
4 | Date : 2017-12-16
5 | Purpose : Example of a bare bones UDP client
6 |
7 | ***********************************************************************/
8 |
9 | #include
10 | #include
11 |
12 | // Include the Winsock library (lib) file
13 | #pragma comment (lib, "ws2_32.lib")
14 |
15 | // Saves us from typing std::cout << etc. etc. etc.
16 | using namespace std;
17 |
18 | void main(int argc, char* argv[]) // We can pass in a command line option!!
19 | {
20 | ////////////////////////////////////////////////////////////
21 | // INITIALIZE WINSOCK
22 | ////////////////////////////////////////////////////////////
23 |
24 | // Structure to store the WinSock version. This is filled in
25 | // on the call to WSAStartup()
26 | WSADATA data;
27 |
28 | // To start WinSock, the required version must be passed to
29 | // WSAStartup(). This server is going to use WinSock version
30 | // 2 so I create a word that will store 2 and 2 in hex i.e.
31 | // 0x0202
32 | WORD version = MAKEWORD(2, 2);
33 |
34 | // Start WinSock
35 | int wsOk = WSAStartup(version, &data);
36 | if (wsOk != 0)
37 | {
38 | // Not ok! Get out quickly
39 | cout << "Can't start Winsock! " << wsOk;
40 | return;
41 | }
42 |
43 | ////////////////////////////////////////////////////////////
44 | // CONNECT TO THE SERVER
45 | ////////////////////////////////////////////////////////////
46 |
47 | // Create a hint structure for the server
48 | sockaddr_in server;
49 | server.sin_family = AF_INET; // AF_INET = IPv4 addresses
50 | server.sin_port = htons(54000); // Little to big endian conversion
51 | inet_pton(AF_INET, "127.0.0.1", &server.sin_addr); // Convert from string to byte array
52 |
53 | // Socket creation, note that the socket type is datagram
54 | SOCKET out = socket(AF_INET, SOCK_DGRAM, 0);
55 |
56 | // Write out to that socket
57 | string s(argv[1]);
58 | int sendOk = sendto(out, s.c_str(), s.size() + 1, 0, (sockaddr*)&server, sizeof(server));
59 |
60 | if (sendOk == SOCKET_ERROR)
61 | {
62 | cout << "That didn't work! " << WSAGetLastError() << endl;
63 | }
64 |
65 | // Close the socket
66 | closesocket(out);
67 |
68 | // Close down Winsock
69 | WSACleanup();
70 | }
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Server/UDP_Server.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UDP_Server", "UDP_Server\UDP_Server.vcxproj", "{945B6A9F-969D-480F-A4E0-BAD736AF3667}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Debug|x64.ActiveCfg = Debug|x64
17 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Debug|x64.Build.0 = Debug|x64
18 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Debug|x86.ActiveCfg = Debug|Win32
19 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Debug|x86.Build.0 = Debug|Win32
20 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Release|x64.ActiveCfg = Release|x64
21 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Release|x64.Build.0 = Release|x64
22 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Release|x86.ActiveCfg = Release|Win32
23 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Server/UDP_Server/UDP_Server.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {945B6A9F-969D-480F-A4E0-BAD736AF3667}
23 | Win32Proj
24 | UDP_Server
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
91 | true
92 |
93 |
94 | Console
95 | true
96 |
97 |
98 |
99 |
100 |
101 |
102 | Level3
103 | Disabled
104 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
105 | true
106 |
107 |
108 | Console
109 | true
110 |
111 |
112 |
113 |
114 | Level3
115 |
116 |
117 | MaxSpeed
118 | true
119 | true
120 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
121 | true
122 |
123 |
124 | Console
125 | true
126 | true
127 | true
128 |
129 |
130 |
131 |
132 | Level3
133 |
134 |
135 | MaxSpeed
136 | true
137 | true
138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
139 | true
140 |
141 |
142 | Console
143 | true
144 | true
145 | true
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Server/UDP_Server/UDP_Server.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/UDPClientServerBasic/UDP_Server/UDP_Server/main.cpp:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 | Name : Example UDP Server
3 | Author : Sloan Kelly
4 | Date : 2017-12-16
5 | Purpose : Example of a bare bones UDP server
6 |
7 | ***********************************************************************/
8 |
9 | #include
10 | #include
11 |
12 | // Include the Winsock library (lib) file
13 | #pragma comment (lib, "ws2_32.lib")
14 |
15 | // Saves us from typing std::cout << etc. etc. etc.
16 | using namespace std;
17 |
18 | // Main entry point into the server
19 | void main()
20 | {
21 | ////////////////////////////////////////////////////////////
22 | // INITIALIZE WINSOCK
23 | ////////////////////////////////////////////////////////////
24 |
25 | // Structure to store the WinSock version. This is filled in
26 | // on the call to WSAStartup()
27 | WSADATA data;
28 |
29 | // To start WinSock, the required version must be passed to
30 | // WSAStartup(). This server is going to use WinSock version
31 | // 2 so I create a word that will store 2 and 2 in hex i.e.
32 | // 0x0202
33 | WORD version = MAKEWORD(2, 2);
34 |
35 | // Start WinSock
36 | int wsOk = WSAStartup(version, &data);
37 | if (wsOk != 0)
38 | {
39 | // Not ok! Get out quickly
40 | cout << "Can't start Winsock! " << wsOk;
41 | return;
42 | }
43 |
44 | ////////////////////////////////////////////////////////////
45 | // SOCKET CREATION AND BINDING
46 | ////////////////////////////////////////////////////////////
47 |
48 | // Create a socket, notice that it is a user datagram socket (UDP)
49 | SOCKET in = socket(AF_INET, SOCK_DGRAM, 0);
50 |
51 | // Create a server hint structure for the server
52 | sockaddr_in serverHint;
53 | serverHint.sin_addr.S_un.S_addr = ADDR_ANY; // Us any IP address available on the machine
54 | serverHint.sin_family = AF_INET; // Address format is IPv4
55 | serverHint.sin_port = htons(54000); // Convert from little to big endian
56 |
57 | // Try and bind the socket to the IP and port
58 | if (bind(in, (sockaddr*)&serverHint, sizeof(serverHint)) == SOCKET_ERROR)
59 | {
60 | cout << "Can't bind socket! " << WSAGetLastError() << endl;
61 | return;
62 | }
63 |
64 | ////////////////////////////////////////////////////////////
65 | // MAIN LOOP SETUP AND ENTRY
66 | ////////////////////////////////////////////////////////////
67 |
68 | sockaddr_in client; // Use to hold the client information (port / ip address)
69 | int clientLength = sizeof(client); // The size of the client information
70 |
71 | char buf[1024];
72 |
73 | // Enter a loop
74 | while (true)
75 | {
76 | ZeroMemory(&client, clientLength); // Clear the client structure
77 | ZeroMemory(buf, 1024); // Clear the receive buffer
78 |
79 | // Wait for message
80 | int bytesIn = recvfrom(in, buf, 1024, 0, (sockaddr*)&client, &clientLength);
81 | if (bytesIn == SOCKET_ERROR)
82 | {
83 | cout << "Error receiving from client " << WSAGetLastError() << endl;
84 | continue;
85 | }
86 |
87 | // Display message and client info
88 | char clientIp[256]; // Create enough space to convert the address byte array
89 | ZeroMemory(clientIp, 256); // to string of characters
90 |
91 | // Convert from byte array to chars
92 | inet_ntop(AF_INET, &client.sin_addr, clientIp, 256);
93 |
94 | // Display the message / who sent it
95 | cout << "Message recv from " << clientIp << " : " << buf << endl;
96 | }
97 |
98 | // Close socket
99 | closesocket(in);
100 |
101 | // Shutdown winsock
102 | WSACleanup();
103 | }
104 |
--------------------------------------------------------------------------------