Rather than having to check the address. This means that we don't need
to initialize `cw.me' if we /aren't/ listening, so don't.
} pkstream;
typedef struct connwait {
} pkstream;
typedef struct connwait {
+ unsigned f; /* Various flags */
+#define cwf_port 1u /* Port is defined => listen */
sel_file a; /* Selector */
struct sockaddr_in me, peer; /* Who I'm meant to be; who peer is */
} connwait;
sel_file a; /* Selector */
struct sockaddr_in me, peer; /* Who I'm meant to be; who peer is */
} connwait;
- if (cw.me.sin_port) dolisten();
+ if (cw.f&cwf_port) dolisten();
ego(argv[0]);
sel_init(&sel);
for (;;) {
ego(argv[0]);
sel_init(&sel);
for (;;) {
if (bindsvc && connhost)
die(1, "can't listen and connect");
if (bindsvc && connhost)
die(1, "can't listen and connect");
if (bindhost || bindsvc) {
initaddr(&bindaddr);
if (!bindsvc) parseaddr(bindhost, 0, 0, &bindaddr);
if (bindhost || bindsvc) {
initaddr(&bindaddr);
if (!bindsvc) parseaddr(bindhost, 0, 0, &bindaddr);
- else parseaddr(bindhost, bindsvc, 0, &cw.me);
+ else {
+ initaddr(&cw.me);
+ parseaddr(bindhost, bindsvc, 0, &cw.me);
+ cw.f |= cwf_port;
+ }