mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
./brmlife -p PORT: Implement commandline override
This commit is contained in:
parent
f9f5becd16
commit
643e33c342
1 changed files with 5 additions and 3 deletions
8
main.cc
8
main.cc
|
@ -54,15 +54,17 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int w = 40, h = 20;
|
int w = 40, h = 20;
|
||||||
int herbs_opt = -1;
|
int herbs_opt = -1;
|
||||||
|
int port = 27753;
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "h:x:y:")) != -1) {
|
while ((opt = getopt(argc, argv, "h:p:x:y:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h': herbs_opt = atoi(optarg); break;
|
case 'h': herbs_opt = atoi(optarg); break;
|
||||||
|
case 'p': port = atoi(optarg); break;
|
||||||
case 'x': w = atoi(optarg); break;
|
case 'x': w = atoi(optarg); break;
|
||||||
case 'y': h = atoi(optarg); break;
|
case 'y': h = atoi(optarg); break;
|
||||||
default: /* '?' */
|
default: /* '?' */
|
||||||
fprintf(stderr, "Usage: %s [-h HERBS] [-x WIDTH] [-y HEIGHT]\n",
|
fprintf(stderr, "Usage: %s [-h HERBS] [-p PORT] [-x WIDTH] [-y HEIGHT]\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +84,7 @@ main(int argc, char *argv[])
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
memset(&sin, 0, sizeof(sin));
|
memset(&sin, 0, sizeof(sin));
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_port = htons(27753);
|
sin.sin_port = htons(port);
|
||||||
sin.sin_addr.s_addr = INADDR_ANY;
|
sin.sin_addr.s_addr = INADDR_ANY;
|
||||||
int optval = 1;
|
int optval = 1;
|
||||||
setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
|
setsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue