C programming:  Fill Out the TODO'S IN THE PROGRAM :   #include // EXIT_ codes #include // bool #include // printf, scanf #include // strlen, strcmp #include "udp.h" // udp library #define CLIENT_LISTENER_PORT 4097 #define SERVER_LISTENER_PORT 4098 #define MAX_CHARS_PER_MESSAGE 80 //----------------------------------------------------------------------------- // Main //----------------------------------------------------------------------------- int main(int argc, char* argv[]) { char *remoteIp; char *mode; int remotePort; char str[MAX_CHARS_PER_MESSAGE+1]; bool quit = false; bool sendMode; // Verify arguments are good bool goodArguments = (argc == 3); if (goodArguments) { remoteIp = argv[1]; mode = argv[2]; goodArguments = (strcmp(mode, "server") == 0) || (strcmp(mode, "client") == 0); } if (!goodArguments) { printf("usage: chat IPV4_ADDRESS MODE\n"); printf(" where:\n"); printf(" IPV4_ADDRESS is address of the remote machine\n"); printf(" MODE is either client or server\n"); exit(EXIT_FAILURE); } // Determine if client or server               bool client = strcmp(mode, "client") == 0; // TODO: Open udp listener port number dependent on client/server role // TODO: Determine remote port that you will send data to // If you are server, send to client port, and vice versa // TODO: Determine if it is your turn to send data or not, // based on server or client mode // sendMode = ... // Display warning to not use spaces printf("NOTE: When sending messages, DO NOT include spaces\n"); // Start chat loop, alternating between sending and receiving messages while(!quit) { // send text if (sendMode) { // TODO: Add code to get string from user and send // TODO: Handle an error is sendUdpMessage returns false // TODO: Leave while loop if QUIT was sent } // wait for text else { // TODO: Add code to wait for a string from remote user // TODO: Leave while loop if QUIT is received } // alternate between send and receive mode sendMode = !sendMode; } // TODO: Close udp listener port return EXIT_SUCCESS; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C programming: 

Fill Out the TODO'S IN THE PROGRAM :
 
#include <stdlib.h> // EXIT_ codes
#include <stdbool.h> // bool
#include <stdio.h> // printf, scanf
#include <string.h> // strlen, strcmp
#include "udp.h" // udp library
#define CLIENT_LISTENER_PORT 4097
#define SERVER_LISTENER_PORT 4098
#define MAX_CHARS_PER_MESSAGE 80
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
char *remoteIp;
char *mode;
int remotePort;
char str[MAX_CHARS_PER_MESSAGE+1];
bool quit = false;
bool sendMode;
// Verify arguments are good
bool goodArguments = (argc == 3);
if (goodArguments)
{
remoteIp = argv[1];
mode = argv[2];
goodArguments = (strcmp(mode, "server") == 0) || (strcmp(mode, "client") ==
0);
}
if (!goodArguments)
{
printf("usage: chat IPV4_ADDRESS MODE\n");
printf(" where:\n");
printf(" IPV4_ADDRESS is address of the remote machine\n");
printf(" MODE is either client or server\n");
exit(EXIT_FAILURE);
}
// Determine if client or server
 
 
 
 
 
 
 
bool client = strcmp(mode, "client") == 0;
// TODO: Open udp listener port number dependent on client/server role
// TODO: Determine remote port that you will send data to
// If you are server, send to client port, and vice versa
// TODO: Determine if it is your turn to send data or not,
// based on server or client mode
// sendMode = ...
// Display warning to not use spaces
printf("NOTE: When sending messages, DO NOT include spaces\n");
// Start chat loop, alternating between sending and receiving messages
while(!quit)
{
// send text
if (sendMode)
{
// TODO: Add code to get string from user and send
// TODO: Handle an error is sendUdpMessage returns false
// TODO: Leave while loop if QUIT was sent
}
// wait for text
else
{
// TODO: Add code to wait for a string from remote user
// TODO: Leave while loop if QUIT is received
}
// alternate between send and receive mode
sendMode = !sendMode;
}
// TODO: Close udp listener port

return EXIT_SUCCESS;
}
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Network Protocols
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education