/* * Copyright (C) 2017 Ortega Froysa, Nicolás * Author: Ortega Froysa, Nicolás * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #include #include #include int run = 1; void quit(int sig) { puts("\nInterrupt signal received."); run = 0; } int main(int argc, char *argv[]) { if(argc != 2 && argc != 4) { printf("Usage: %s [ ]\n", argv[0]); return 1; } unsigned short port = atoi(argv[1]); char *connect_address = NULL; unsigned short connect_port = 0; if(argc == 4) { connect_address = argv[2]; connect_port = atoi(argv[3]); } if(!NeoComm_init(port)) { fprintf(stderr, "%s\n", NeoComm_get_last_error()); return 1; } signal(SIGINT, quit); if(connect_address) NeoComm_connect(connect_address, connect_port); while(run) { } NeoComm_deinit(); return 0; }