mirror of https://github.com/fltk/fltk
Remove mcast and dnd test programs. I do like them and they should be back eventually, however right now they ae not in the scope of the UTF8 port.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6216 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
5ef343568c
commit
cf61ea83a4
|
@ -48,7 +48,6 @@ CPPFILES =\
|
||||||
cursor.cxx \
|
cursor.cxx \
|
||||||
curve.cxx \
|
curve.cxx \
|
||||||
demo.cxx \
|
demo.cxx \
|
||||||
dnd-test.cxx \
|
|
||||||
doublebuffer.cxx \
|
doublebuffer.cxx \
|
||||||
editor.cxx \
|
editor.cxx \
|
||||||
fast_slow.cxx \
|
fast_slow.cxx \
|
||||||
|
@ -94,10 +93,7 @@ CPPFILES =\
|
||||||
tile.cxx \
|
tile.cxx \
|
||||||
tiled_image.cxx \
|
tiled_image.cxx \
|
||||||
valuators.cxx \
|
valuators.cxx \
|
||||||
utf8.cxx \
|
utf8.cxx
|
||||||
mcast_launcher.cxx \
|
|
||||||
mcast_tx.cxx \
|
|
||||||
mcast_rx.cxx
|
|
||||||
|
|
||||||
ALL = \
|
ALL = \
|
||||||
unittests$(EXEEXT) \
|
unittests$(EXEEXT) \
|
||||||
|
@ -117,7 +113,6 @@ ALL = \
|
||||||
cursor$(EXEEXT) \
|
cursor$(EXEEXT) \
|
||||||
curve$(EXEEXT) \
|
curve$(EXEEXT) \
|
||||||
demo$(EXEEXT) \
|
demo$(EXEEXT) \
|
||||||
dnd-test$(EXEEXT) \
|
|
||||||
doublebuffer$(EXEEXT) \
|
doublebuffer$(EXEEXT) \
|
||||||
editor$(EXEEXT) \
|
editor$(EXEEXT) \
|
||||||
fast_slow$(EXEEXT) \
|
fast_slow$(EXEEXT) \
|
||||||
|
@ -158,10 +153,7 @@ ALL = \
|
||||||
tile$(EXEEXT) \
|
tile$(EXEEXT) \
|
||||||
tiled_image$(EXEEXT) \
|
tiled_image$(EXEEXT) \
|
||||||
valuators$(EXEEXT) \
|
valuators$(EXEEXT) \
|
||||||
utf8$(EXEEXT) \
|
utf8$(EXEEXT)
|
||||||
mcast_launcher$(EXEEXT) \
|
|
||||||
mcast_tx$(EXEEXT) \
|
|
||||||
mcast_rx$(EXEEXT)
|
|
||||||
|
|
||||||
|
|
||||||
GLALL = \
|
GLALL = \
|
||||||
|
|
|
@ -50,8 +50,6 @@
|
||||||
@u:keyboard:keyboard
|
@u:keyboard:keyboard
|
||||||
@u:fast && slow widgets:fast_slow
|
@u:fast && slow widgets:fast_slow
|
||||||
@u:inactive:inactive
|
@u:inactive:inactive
|
||||||
# @u:Drag Drop:dnd-test
|
|
||||||
# @u:add_fd():mcast_launcher
|
|
||||||
|
|
||||||
@main:Fluid\n(UI design tool):../fluid/fluid valuators.fl
|
@main:Fluid\n(UI design tool):../fluid/fluid valuators.fl
|
||||||
|
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
/* This is just a simple wrapper app that launches two independent processes then exits...
|
|
||||||
* I use it because the fltk test/demo program launches one process per button, and I wanted
|
|
||||||
* to launch several in my multicast/Fl::add_fd() test harness.
|
|
||||||
*
|
|
||||||
* This code also shows how to find the "home" directory for any executable in a cross-platform
|
|
||||||
* way, which can be handy for finding resources or help files.
|
|
||||||
*/
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <windows.h> /* GetModuleFileName */
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifdef __APPLE__ /* assume this is OSX */
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <mach-o/dyld.h> /* _NSGetExecutablePath : must add -framework CoreFoundation to link line */
|
|
||||||
#include <string.h>
|
|
||||||
# ifndef PATH_MAX
|
|
||||||
# define PATH_MAX MAXPATHLEN
|
|
||||||
# endif
|
|
||||||
#endif /* APPLE */
|
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
|
||||||
# define PATH_MAX 2048
|
|
||||||
#endif
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static int get_app_path (char *pname, size_t pathsize)
|
|
||||||
{
|
|
||||||
long result;
|
|
||||||
|
|
||||||
#if defined (WIN32)
|
|
||||||
result = GetModuleFileName(NULL, pname, pathsize);
|
|
||||||
if (result > 0) {
|
|
||||||
/* fix up the dir slashes... */
|
|
||||||
int len = strlen(pname);
|
|
||||||
int idx;
|
|
||||||
for (idx = 0; idx < len; idx++) {
|
|
||||||
if (pname[idx] == '\\') pname[idx] = '/';
|
|
||||||
}
|
|
||||||
if ((access(pname, 0) == 0)) {
|
|
||||||
return 0; /* file exists, return OK */
|
|
||||||
}
|
|
||||||
/*else name doesn't seem to exist, return FAIL (falls through) */
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined (SOLARIS) // we used to set this for our all our Sun builds - I wonder what Sun set...?
|
|
||||||
char *p = getexecname();
|
|
||||||
if (p) {
|
|
||||||
/* According to the Sun manpages, getexecname will "normally" return an */
|
|
||||||
/* absolute path - BUT might not... AND that IF it is not, pre-pending */
|
|
||||||
/* getcwd() will "usually" be the correct thing... Urgh! */
|
|
||||||
|
|
||||||
/* check pathname is absolute (begins with a / ) */
|
|
||||||
if (p[0] == '/') { /* assume this means we have an absolute path */
|
|
||||||
strncpy(pname, p, pathsize);
|
|
||||||
if ((access(pname, 0) == 0))
|
|
||||||
return 0; /* file exists, return OK */
|
|
||||||
} else { /* if not, prepend getcwd() then check if file exists */
|
|
||||||
getcwd(pname, pathsize);
|
|
||||||
result = strlen(pname);
|
|
||||||
strncat(pname, "/", (pathsize - result));
|
|
||||||
result ++;
|
|
||||||
strncat(pname, p, (pathsize - result));
|
|
||||||
|
|
||||||
if ((access(pname, 0) == 0))
|
|
||||||
return 0; /* file exists, return OK */
|
|
||||||
/*else name doesn't seem to exist, return FAIL (falls through) */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined (__APPLE__) /* assume this is OSX */
|
|
||||||
/* extern int _NSGetExecutablePath(char *buf, unsigned long *bufsize);
|
|
||||||
|
|
||||||
_NSGetExecutablePath copies the path of the executable
|
|
||||||
into the buffer and returns 0 if the path was successfully
|
|
||||||
copied in the provided buffer. If the buffer is not large
|
|
||||||
enough, -1 is returned and the expected buffer size is
|
|
||||||
copied in *bufsize. Note that _NSGetExecutablePath will
|
|
||||||
return "a path" to the executable not a "real path" to the
|
|
||||||
executable. That is the path may be a symbolic link and
|
|
||||||
not the real file. And with deep directories the total
|
|
||||||
bufsize needed could be more than MAXPATHLEN.
|
|
||||||
*/
|
|
||||||
int status = -1;
|
|
||||||
char *given_path = (char *)malloc(MAXPATHLEN * 2);
|
|
||||||
if (!given_path) return status;
|
|
||||||
|
|
||||||
pathsize = MAXPATHLEN * 2;
|
|
||||||
result = _NSGetExecutablePath(given_path, (uint32_t *)&pathsize);
|
|
||||||
if (result == 0) { /* OK, we got something - now try and resolve the real path... */
|
|
||||||
if (realpath(given_path, pname) != NULL) {
|
|
||||||
if ((access(pname, 0) == 0)) {
|
|
||||||
status = 0; /* file exists, return OK */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free (given_path);
|
|
||||||
return status;
|
|
||||||
|
|
||||||
#else // just assume this is linux for now - not valid - what about BSD's etc...?
|
|
||||||
/* Oddly, the readlink(2) man page says no NULL is appended. */
|
|
||||||
/* So you have to do it yourself, based on the return value: */
|
|
||||||
pathsize --; /* Preserve a space to add the trailing NULL */
|
|
||||||
result = readlink("/proc/self/exe", pname, pathsize);
|
|
||||||
|
|
||||||
if (result > 0) {
|
|
||||||
pname[result] = 0; /* add a terminating NULL */
|
|
||||||
|
|
||||||
if ((access(pname, 0) == 0)) {
|
|
||||||
return 0; /* file exists, return OK */
|
|
||||||
}
|
|
||||||
/*else name doesn't seem to exist, return FAIL (falls through) */
|
|
||||||
}
|
|
||||||
#endif /* LINUX (assumed!) */
|
|
||||||
|
|
||||||
return -1; /* Path Lookup Failed */
|
|
||||||
} // get_app_path
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void app_launch(const char *cmd)
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
// Under win32 you can't just use "system" and background the process to easily launch
|
|
||||||
// another executable - so we use spawn instead...
|
|
||||||
_spawnl(_P_NOWAIT, cmd, cmd, NULL);
|
|
||||||
#else
|
|
||||||
// On other systems, just use system to launch the executable
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
snprintf(buf, PATH_MAX, "%s &", cmd);
|
|
||||||
system(buf);
|
|
||||||
#endif
|
|
||||||
} // app_launch
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
char launcher_path[PATH_MAX];
|
|
||||||
char exe_path[PATH_MAX];
|
|
||||||
// Find where the launcher app lives - we assume the test executables are in the same location
|
|
||||||
int fail = get_app_path (launcher_path, PATH_MAX);
|
|
||||||
if (fail) // couldn't get a valid path...
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
// not all supported platfoms provide a dirname function - do a simplified version here
|
|
||||||
strncpy(exe_path, launcher_path, PATH_MAX);
|
|
||||||
// find the last dir sep (note that get_app_path uses '/' on win32 also)
|
|
||||||
char *dirp = strrchr(exe_path, '/');
|
|
||||||
dirp ++; // first char after the dir slash
|
|
||||||
*dirp = 0; // terminate the path, removing the executables basename
|
|
||||||
|
|
||||||
strncat(exe_path, "mcast_tx", PATH_MAX);
|
|
||||||
app_launch(exe_path); // launch the sender
|
|
||||||
|
|
||||||
*dirp = 0; // terminate the path - again
|
|
||||||
strncat(exe_path, "mcast_rx", PATH_MAX);
|
|
||||||
app_launch(exe_path); // launch the receiver
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* end of file */
|
|
|
@ -1,160 +0,0 @@
|
||||||
/* Test multicast operation and Fl::add_fd functionality */
|
|
||||||
/* This file is the multicast Receiver - there can be multiple instances
|
|
||||||
* of this running during the test. A minimum of one is good...! */
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# include <windows.h>
|
|
||||||
# include <winsock2.h>
|
|
||||||
# include <ws2tcpip.h>
|
|
||||||
# define CLOSESKT closesocket
|
|
||||||
#else
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <netinet/in.h>
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# define CLOSESKT close
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
|
||||||
#include <FL/Fl_Double_Window.H>
|
|
||||||
#include <FL/Fl_Browser.H>
|
|
||||||
#include <FL/Fl_Button.H>
|
|
||||||
#include <FL/Fl_Round_Button.H>
|
|
||||||
|
|
||||||
// define an arbitrary multicast address with organisation-local scope
|
|
||||||
static char madrs[] = "239.192.34.56";
|
|
||||||
#define SERVER_PORT 5678
|
|
||||||
#define MAX_MSG 100
|
|
||||||
|
|
||||||
static Fl_Double_Window *rx_win;
|
|
||||||
static Fl_Browser *rx_brws;
|
|
||||||
static Fl_Button *exit_bt;
|
|
||||||
static Fl_Round_Button *wait_bt;
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void cb_exit_bt(Fl_Button*, void*) {
|
|
||||||
rx_win->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void led_flash(void*) {
|
|
||||||
static int led = 0;
|
|
||||||
led = led ^ 1;
|
|
||||||
wait_bt->value(led);
|
|
||||||
Fl::repeat_timeout(0.4, led_flash);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void skt_cb(int skt, void*) {
|
|
||||||
struct sockaddr_in cliAddr;
|
|
||||||
char msg[MAX_MSG];
|
|
||||||
socklen_t cliLen = sizeof (cliAddr);
|
|
||||||
int n = recvfrom (skt, msg, MAX_MSG, 0, (struct sockaddr *)&cliAddr, &cliLen);
|
|
||||||
if (n < 0) return;
|
|
||||||
rx_brws->add(msg);
|
|
||||||
int last = rx_brws->size();
|
|
||||||
rx_brws->bottomline(last);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
// First, create the socket layer
|
|
||||||
int skt, res;
|
|
||||||
struct ip_mreq mreq;
|
|
||||||
struct sockaddr_in servAddr;
|
|
||||||
struct in_addr mcastAddr;
|
|
||||||
struct hostent *h;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
// On win32, make sure the winsock layer is started
|
|
||||||
WSADATA WSAData;
|
|
||||||
WSAStartup (MAKEWORD (1, 1), &WSAData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* set mcast address to listen to */
|
|
||||||
h = gethostbyname(madrs);
|
|
||||||
if (h == NULL) {
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&mcastAddr, h->h_addr_list[0], h->h_length);
|
|
||||||
|
|
||||||
/* create the socket */
|
|
||||||
skt = socket (AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (skt < 0) {
|
|
||||||
fprintf (stderr, "cannot create socket\n");
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set socket to allow re-use of local address before bind() - this should allow us to have
|
|
||||||
* multiple receiver instances all running at once. */
|
|
||||||
int bReUse = 1;
|
|
||||||
setsockopt(skt, SOL_SOCKET, SO_REUSEADDR, (char *)&bReUse, sizeof(bReUse));
|
|
||||||
|
|
||||||
// Populate the servAddr struct
|
|
||||||
servAddr.sin_family = AF_INET;
|
|
||||||
servAddr.sin_addr.s_addr = htonl (INADDR_ANY);
|
|
||||||
servAddr.sin_port = htons (SERVER_PORT);
|
|
||||||
|
|
||||||
/* bind port */
|
|
||||||
if (bind (skt, (struct sockaddr *) &servAddr, sizeof (servAddr)) < 0) {
|
|
||||||
fprintf(stderr, "cannot bind port %d \n", SERVER_PORT);
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* join multicast group */
|
|
||||||
mreq.imr_multiaddr.s_addr = mcastAddr.s_addr;
|
|
||||||
mreq.imr_interface.s_addr = htonl (INADDR_ANY);
|
|
||||||
|
|
||||||
res = setsockopt(skt, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq));
|
|
||||||
if (res != 0) {
|
|
||||||
fprintf(stderr, "cannot join multicast group '%s'", inet_ntoa(mcastAddr));
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now create the fltk display window
|
|
||||||
rx_win = new Fl_Double_Window(600, 100, 447, 338, "Receiver");
|
|
||||||
rx_win->begin();
|
|
||||||
|
|
||||||
// A browser to display the rx'd text in
|
|
||||||
rx_brws = new Fl_Browser(10, 10, 285, 310);
|
|
||||||
rx_brws->when(FL_WHEN_NEVER);
|
|
||||||
|
|
||||||
// quit button
|
|
||||||
exit_bt = new Fl_Button(360, 290, 64, 30, "Quit");
|
|
||||||
exit_bt->box(FL_THIN_UP_BOX);
|
|
||||||
exit_bt->callback((Fl_Callback*)cb_exit_bt);
|
|
||||||
|
|
||||||
// flashing red "waiting" led...
|
|
||||||
wait_bt = new Fl_Round_Button(320, 20, 69, 30, "Waiting");
|
|
||||||
wait_bt->selection_color(FL_RED);
|
|
||||||
wait_bt->when(FL_WHEN_NEVER);
|
|
||||||
wait_bt->clear_visible_focus();
|
|
||||||
|
|
||||||
rx_win->end();
|
|
||||||
|
|
||||||
// display the Rx window
|
|
||||||
rx_win->show(argc, argv);
|
|
||||||
|
|
||||||
// Start the "waiting led" flashing
|
|
||||||
Fl::add_timeout(0.4, led_flash);
|
|
||||||
|
|
||||||
// Add the socket to the add_fd check list
|
|
||||||
Fl::add_fd(skt, skt_cb);
|
|
||||||
|
|
||||||
// run the fltk core
|
|
||||||
res = Fl::run();
|
|
||||||
|
|
||||||
/* close socket and exit */
|
|
||||||
CLOSESKT(skt);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of File */
|
|
|
@ -1,144 +0,0 @@
|
||||||
/* Test multicast operation and Fl::add_fd functionality */
|
|
||||||
/* This file is the multicast Transmitter - there should be one instance
|
|
||||||
* of this running during the test. */
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# include <winsock2.h>
|
|
||||||
# include <ws2tcpip.h>
|
|
||||||
# define CLOSESKT closesocket
|
|
||||||
#else
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <netinet/in.h>
|
|
||||||
# include <arpa/inet.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# define CLOSESKT close
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
|
||||||
#include <FL/Fl_Double_Window.H>
|
|
||||||
#include <FL/Fl_Button.H>
|
|
||||||
#include <FL/Fl_Round_Button.H>
|
|
||||||
|
|
||||||
// define an arbitrary multicast address with organisation-local scope
|
|
||||||
static char madrs[] = "239.192.34.56";
|
|
||||||
#define SERVER_PORT 5678
|
|
||||||
|
|
||||||
static Fl_Double_Window *tx_win;
|
|
||||||
static Fl_Button *send_bt;
|
|
||||||
static Fl_Button *exit_bt;
|
|
||||||
static Fl_Round_Button *ready_bt;
|
|
||||||
|
|
||||||
static int skt;
|
|
||||||
static struct sockaddr_in servAddr;
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void cb_exit_bt(Fl_Button*, void*) {
|
|
||||||
tx_win->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void led_flash(void*) {
|
|
||||||
static int led = 0;
|
|
||||||
led = led ^ 1;
|
|
||||||
ready_bt->value(led);
|
|
||||||
Fl::repeat_timeout(0.4, led_flash);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
static void send_cb(Fl_Button*, void*) { /* send some data */
|
|
||||||
static int msg_idx = 0;
|
|
||||||
char msg[128];
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
sprintf(msg, "Message text %d", msg_idx);
|
|
||||||
msg_idx++;
|
|
||||||
sendto(skt, msg, strlen(msg) + 1, 0, (struct sockaddr *)&servAddr, sizeof(servAddr));
|
|
||||||
} /* end for */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************************/
|
|
||||||
int main (int argc, char *argv[])
|
|
||||||
{
|
|
||||||
// First prepare the socket layer code
|
|
||||||
struct sockaddr_in cliAddr;
|
|
||||||
struct hostent *h;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
// On win32, make sure the winsock layer is started
|
|
||||||
WSADATA WSAData;
|
|
||||||
WSAStartup (MAKEWORD (1, 1), &WSAData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
h = gethostbyname(madrs);
|
|
||||||
if (h == NULL) {
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate the servAddr struct with the requested values
|
|
||||||
servAddr.sin_family = h->h_addrtype;
|
|
||||||
memcpy ((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
|
|
||||||
servAddr.sin_port = htons (SERVER_PORT);
|
|
||||||
|
|
||||||
/* create the socket */
|
|
||||||
skt = socket (AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (skt < 0) {
|
|
||||||
fprintf(stderr, "cannot open socket\n");
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* bind port number */
|
|
||||||
cliAddr.sin_family = AF_INET;
|
|
||||||
cliAddr.sin_addr.s_addr = htonl(INADDR_ANY); // assume default eth_if is fine
|
|
||||||
cliAddr.sin_port = htons (0);
|
|
||||||
if (bind(skt, (struct sockaddr *)&cliAddr, sizeof(cliAddr)) < 0) {
|
|
||||||
fprintf(stderr, "cannot bind port %d \n", SERVER_PORT);
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the IP TTL to 1, so our multicast datagrams can not get off the local network */
|
|
||||||
char ttl = 1;
|
|
||||||
setsockopt (skt, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
|
|
||||||
|
|
||||||
// Now create the fltk window
|
|
||||||
tx_win = new Fl_Double_Window(100, 100, 447, 338, "Sender");
|
|
||||||
tx_win->begin();
|
|
||||||
|
|
||||||
// msg send button
|
|
||||||
send_bt = new Fl_Button(100, 100, 100, 50, "SEND");
|
|
||||||
send_bt->box(FL_THIN_UP_BOX);
|
|
||||||
send_bt->callback((Fl_Callback*)send_cb);
|
|
||||||
|
|
||||||
// quit button
|
|
||||||
exit_bt = new Fl_Button(360, 290, 64, 30, "Quit");
|
|
||||||
exit_bt->box(FL_THIN_UP_BOX);
|
|
||||||
exit_bt->callback((Fl_Callback*)cb_exit_bt);
|
|
||||||
|
|
||||||
// flashing green "ready" led...
|
|
||||||
ready_bt = new Fl_Round_Button(320, 20, 69, 30, "Ready");
|
|
||||||
ready_bt->selection_color(FL_GREEN);
|
|
||||||
ready_bt->when(FL_WHEN_NEVER);
|
|
||||||
ready_bt->clear_visible_focus();
|
|
||||||
|
|
||||||
tx_win->end();
|
|
||||||
|
|
||||||
// display the Tx window
|
|
||||||
tx_win->show(argc, argv);
|
|
||||||
|
|
||||||
// Start the "ready led" flashing
|
|
||||||
Fl::add_timeout(0.4, led_flash);
|
|
||||||
|
|
||||||
// run the fltk core
|
|
||||||
int res = Fl::run();
|
|
||||||
|
|
||||||
/* close socket and exit */
|
|
||||||
CLOSESKT(skt);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of File */
|
|
Loading…
Reference in New Issue