Commit 481972e3 authored by Průšová Kateřina's avatar Průšová Kateřina 😕
Browse files

strace

parent 1b70bb98
File mode changed from 100644 to 100755
......@@ -23,9 +23,9 @@ int tcp_server()
socklen_t clientAddressLength;
struct sockaddr_in clientAddress, serverAddress;
char line[LINE_ARRAY_SIZE];
const char* idenification = "socket";
const char* identifier = "socket";
openlog(idenification, LOG_ODELAY, LOG_DEBUG);
openlog(identifier, LOG_ODELAY, LOG_DEBUG);
cout << "Enter port number to listen on (between 1500 and 65000): ";
cin >> listenPort;
......@@ -83,7 +83,7 @@ int tcp_server()
// inet_ntoa() converts an IP address from binary form to the
// standard "numbers and dots" notation.
cout << " connected to " << inet_ntoa(clientAddress.sin_addr);
syslog(1, "%s %s", inet_ntoa(clientAddress.sin_addr), "logged on server")
syslog(1, "%s %s", inet_ntoa(clientAddress.sin_addr), "logged on server");
// Show the client's port number.
// ntohs() converts a short int from network byte order (which is
......@@ -97,14 +97,14 @@ int tcp_server()
// First set line to all zeroes, so we'll know where the end of
// the string is.
memset(line, 0x0, LINE_ARRAY_SIZE);
int message_length = 0;
int length = 0;
while (recv(connectSocket, line, MAX_MSG, 0) > 0) {
cout << " -- " << line << "\n";
// Convert line to upper case.
for (i = 0; line[i] != '\0'; i++)
line[i] = toupper(line[i]);
message_length++;
length++;
// Send converted line back to client.
if (send(connectSocket, line, strlen(line) + 1, 0) < 0)
......@@ -112,7 +112,7 @@ int tcp_server()
memset(line, 0x0, LINE_ARRAY_SIZE); // set line to all zeroes
}
syslog(1, "%s %d", "message_length:", message_length);
syslog(1, "%s %d", "message_length:", length);
}
return (0);
}
......@@ -68,6 +68,34 @@ Tasks
Make also sure that names of library methods are printed in readable format (not mangled).
Hint: use abilities of the respective tools as much as possible for this purpose, instead of shell scripts and basic linux utilities (grep, wc).
Include all the commands that you used to fulfill this task.
% strace -c ./server
Welcome to the TCP server
Enter port number to listen on (between 1500 and 65000): 4273
Waiting for TCP connection on port 4273 ...
^Cstrace: Process 2655 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 11 read
0.00 0.000000 0 3 write
0.00 0.000000 0 5 close
0.00 0.000000 0 7 fstat
0.00 0.000000 0 6 lseek
0.00 0.000000 0 22 mmap
0.00 0.000000 0 7 mprotect
0.00 0.000000 0 1 munmap
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 socket
0.00 0.000000 0 1 bind
0.00 0.000000 0 1 listen
0.00 0.000000 0 1 execve
0.00 0.000000 0 2 1 arch_prctl
0.00 0.000000 0 5 openat
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 77 2 total
6. Submit an archive containing the protocol, modified sources (complete, not just
a diff with your changes), all necessary libraries, and configuration files.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment