| gclib 1.34.15 Communications API for Galil controllers and PLCs |

remote_server_example.cpp
Go to the documentation of this file.
1
9 #include "examples.h"
10
11 #include <iostream> //std::cout
12 #include <string> //std::getline
13
14 using namespace std;
15
17
21 int main(int argc, char * argv[])
22 {
23 char buf[G_SMALL_BUFFER];
24 int rc = GALIL_EXAMPLE_OK;
25
26 try
27 {
28 std::string server_name;
29
30 if (argc != 2) //Invalid number of arguments
31 {
32 std::cout << "Enter name of your server: ";
33 std::getline(std::cin, server_name);
34 }
35 else
36 {
37 server_name = argv[1]; //Retrieve address from command line
38 }
39
40 //Demonstrates various uses of GPublishServer().
41 remote_server(server_name.c_str());
42 }
43 catch (GReturn gr)
44 {
45 error(nullptr, gr);
46 pause();
47 return GALIL_EXAMPLE_ERROR;
48 }
49
50 pause();
51 return GALIL_EXAMPLE_OK;
52 }
examples.h
GReturn
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
Definition: gclib.h:93
G_SMALL_BUFFER
#define G_SMALL_BUFFER
Most reads from Galil are small. This value will easily hold most, e.g. TH, TZ, etc.
Definition: gclib.h:89
main
int main(int argc, char *argv[])
Main function for Commands Example.
Definition: commands_example.cpp:18
remote_server
GReturn remote_server(const char *server_name)
Publishes local gcaps server to the network.
Definition: remote_server.cpp:39
error
void error(GCon g, GReturn rc)
An example of error handling and debugging information.
Definition: examples.h:40
pause
int pause()
Pauses console apps for a user key stroke.
Definition: examples.h:62