-
Notifications
You must be signed in to change notification settings - Fork 0
/
services.c
38 lines (33 loc) · 1.06 KB
/
services.c
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
/*
* services.c: Provides all services after persistant TCP connection established
* This file is a part of Tutor
*
* Tutor is an application to create a tutor relationship tree using the client-server model.
* Consists of a tutor node (server) and many student nodes (clients).
* This was created as a part of CS 6390 Advanced Computer Networks course at UT Dallas.
*
* Contributors: Avinash Joshi <axj107420@utdallas.edu>, Sandeep Shenoy <sxs115220@utdallas.edu>
*/
#include "myheader.h"
void
compute_path (void) {
char buff[STRLEN];
char temp_buf[10], *path_ptr;
send (parent.established_socket, "compute", strlen("compute"), 0);
recv (parent.established_socket, buff, STRLEN, 0);
sprintf (temp_buf, "%d", node_number);
strcat (buff, ":");
strcat (buff, temp_buf);
/*
* Splitting the received buffer
*/
fprintf (stdout, "\nPath: ");
path_ptr = strtok (buff, ":");
while (path_ptr != NULL) {
fprintf (stdout, "Node (%s)", path_ptr);
path_ptr = strtok (NULL, ":");
if (path_ptr != NULL)
fprintf (stdout, " --> ");
}
DBG (("Path: %s", buff));
}