-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_server_main.cpp
More file actions
60 lines (46 loc) · 1.27 KB
/
simple_server_main.cpp
File metadata and controls
60 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "ServerSocket.h"
#include "SocketException.h"
#include <string>
#include <iostream>
int main ( int argc, int argv[] )
{
std::cout << "running....\n";
std::string gpgga[] ={"--,$GPGGA,185177,0259.956,S,05323.639,E,1,08,0.9,545.4,M,46.9,M,,*57,",
"--,$GPGGA,185180,0259.956,S,05323.639,E,1,08,0.9,545.4,M,46.9,M,,*5F,",
"--,$GPGGA,185183,0259.956,S,05323.639,E,1,08,0.9,545.4,M,46.9,M,,*5C,",
"--,$GPGGA,185186,0259.956,S,05323.639,E,1,08,0.9,545.4,M,46.9,M,,*59,",
"--,$GPGGA,185189,0259.379,S,05324.142,E,1,08,0.9,545.4,M,46.9,M,,*5D,",
"--,$GPGGA,185192,0259.379,S,05324.142,E,1,08,0.9,545.4,M,46.9,M,,*57,",
"--,$GPGGA,185195,0258.102,S,05324.670,E,1,08,0.9,545.4,M,46.9,M,,*59,"
};
try
{
// Create the socket
ServerSocket server ( 30000 );
while ( true )
{
ServerSocket new_sock;
server.accept ( new_sock );
try
{
while ( true )
{
std::string data="awesome stuff from the server";
// new_sock >> data;
int i=0;
while (i<7) {
data=gpgga[i];
new_sock << data;
i++;
}
}
}
catch ( SocketException& ) {}
}
}
catch ( SocketException& e )
{
std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
}
return 0;
}