forked from tigerkelly/fbcurses
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunicast.c
More file actions
47 lines (39 loc) · 1.03 KB
/
unicast.c
File metadata and controls
47 lines (39 loc) · 1.03 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
/*
* Copyright (c) 2026 Richard Kelly Wiles (rkwiles@twc.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "fbcurses.h"
#include "fbnet.h"
#include "fbnet_client.h"
// Unicast
int main(int argc, char *argv[]) {
char ip[18];
unsigned short port;
strcpy(ip, "127.0.0.1");
port = 9876;
for (int i = 1; i < argc; i++) {
if (strncmp(argv[i], "-a", 2) == 0) {
strcpy(ip, argv[i+1]);
} else if (strncmp(argv[i], "-p", 2) == 0) {
port = (unsigned short)atoi(argv[i+1]);
}
}
fbNetClient *cl = fbncOpen(ip, port);
int win = fbncWinNew(cl, 2, 2, 60, 14);
fbncTitleBar(cl, win, "Hello", FBNC_BORDER_DOUBLE,
FBNC_CYAN, FBNC_BLACK, FBNC_CYAN);
fbncPrintAtFmt(cl, win, 4, 4, "Hello from C!");
fbncPrintPx(cl, 50, 200, "Big text", FBNC_BRIGHT_CYAN, FBNC_BLACK,
FBNC_ATTR_NONE, "16x32");
fbncRefreshFlush(cl, win);
fbncClose(cl);
// Multicast
fbNetClient *mc = fbncOpenMcast(FB_NET_MCAST_ALL, port);
fbncClear(mc, 0x000000);
fbncRefreshAllFlush(mc);
fbncClose(mc);
return 0;
}