aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-26 00:21:32 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-26 00:21:32 -0400
commitb0efac86fe8ef8c6265f73fca13cf5d331cec353 (patch)
tree68bb3dc3c5aa1fc5951638577b98ad45017fa469
parent2692310a802b7caf80cc039115698191c2ea05e4 (diff)
revert server
-rw-r--r--client.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/client.c b/client.c
index 17a8a81..dbbc204 100644
--- a/client.c
+++ b/client.c
@@ -24,7 +24,7 @@
#define COMMAND_LINE_MAX 1024
// handles the handshake and returns the number of stations
-u_int16_t handle_handshake(int sockfd, char* udpPort);
+u_int16_t handle_handshake(int sockfd, const char* udp_port);
// routine thread for the command line
void *command_line_routine(void *args);
@@ -96,7 +96,7 @@ main(int argc, char *argv[]) // no int here for good luck :)
// START COMMAND LINE THREAD
// -------------------------------------------------------------------------------------------------
pthread_t command_line_thread;
- pthread_create(&command_line_thread, NULL, command_line_routine, (void*)sockfd);
+ pthread_create(&command_line_thread, NULL, command_line_routine, (void*)&sockfd);
// START WHILE LOOP THAT HANDLES ALL REPLIES
// -------------------------------------------------------------------------------------------------
@@ -184,7 +184,7 @@ main(int argc, char *argv[]) // no int here for good luck :)
// get the string size, which can be farily long (uint32_t)
uint32_t buf_string_size = -1;
int bytes_to_read = sizeof(uint32_t);
- if (recv_all(sockfd, &buf_string_size, &bytes_to_read) == -1) {
+ if (recv_all(sockfd, (char *) &buf_string_size, &bytes_to_read) == -1) {
perror("recv_all 1 in stationinfo");
exit(1);
}
@@ -260,7 +260,7 @@ main(int argc, char *argv[]) // no int here for good luck :)
/* thread for managing the command line */
void *command_line_routine(void* args) {
// unpack sockfd as arg
- int sockfd = (int) args;
+ int sockfd = *(int *) args;
// buffer for input
char input[COMMAND_LINE_MAX];
@@ -331,7 +331,7 @@ void *command_line_routine(void* args) {
// send it
apply_timeout(sockfd); // apply timeout, will be released when we get ANNOUNCE reply
int bytes_to_send = sizeof(struct SetStation);
- if (send_all(sockfd, &setStation, &bytes_to_send) == -1) {
+ if (send_all(sockfd, (char *) &setStation, &bytes_to_send) == -1) {
perror("send_all");
exit(1);
}
@@ -347,7 +347,7 @@ void *command_line_routine(void* args) {
returns the number of stations
note: will close the program on failure!
*/
-uint16_t handle_handshake(int sockfd, char* udp_port) {
+uint16_t handle_handshake(int sockfd, const char* udp_port) {
if (l) printf("found server, sending HELLO command.\n");
apply_timeout(sockfd); // apply timeout for handshake
@@ -359,7 +359,7 @@ uint16_t handle_handshake(int sockfd, char* udp_port) {
int udp_port_int = atoi(udp_port);
hello.udpPort = htons(udp_port_int);
int hello_len = sizeof(struct Hello);
- if (send_all(sockfd, &hello, &hello_len) == -1) {
+ if (send_all(sockfd, (char *) &hello, &hello_len) == -1) {
perror("send");
exit(1);
}
@@ -369,7 +369,7 @@ uint16_t handle_handshake(int sockfd, char* udp_port) {
// read WELCOME reply type
uint8_t reply_type = -1;
// print size of utin8
- if (recv(sockfd, &reply_type, 1, 0) == -1) { // only one byte, so can use recv
+ if (recv(sockfd, (void *) &reply_type, 1, 0) == -1) { // only one byte, so can use recv
perror("recv in handshake");
exit(1);
}
@@ -383,7 +383,7 @@ uint16_t handle_handshake(int sockfd, char* udp_port) {
// get the number of stations
int16_t num_stations = -1;
int bytes_to_read = sizeof(uint16_t);
- if (recv_all(sockfd, &num_stations, &bytes_to_read) == -1) {
+ if (recv_all(sockfd, (char *) &num_stations, &bytes_to_read) == -1) {
perror("recv_all in handshake");
exit(1);
}