@@ -65,6 +65,7 @@ int main(int argc, char *argv[])
65
65
FD_SET (server_sockfd , & readset );
66
66
FD_SET (fileno (stdin ), & readset );
67
67
//wait for clients
68
+ printf (">> " );
68
69
while (1 ){
69
70
70
71
tempset = readset ;
@@ -81,13 +82,12 @@ int main(int argc, char *argv[])
81
82
fd_array [num_clients ] = client_sockfd ;
82
83
83
84
//welcome client
84
- sprintf (message , "Welcome client %d\n" , num_clients );
85
+ sprintf (message , "mWelcome client %d\n" , num_clients );
85
86
write (client_sockfd , message , strlen (message ));
86
87
++ num_clients ;
87
- printf (">> " );
88
88
fflush (stdout );
89
89
}else {
90
- sprintf (message , "Sorry , too many clients connected. Try again later.\n" );
90
+ sprintf (message , "mSorry , too many clients connected. Try again later.\n" );
91
91
write (client_sockfd , message , strlen (message ));
92
92
close (client_sockfd );
93
93
}
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
96
96
fgets (kbd_input , MAX_MSG_SIZE , stdin );
97
97
98
98
if (!strcmp ("quit\n" , kbd_input )){
99
- sprintf (message , "Server shutting down!\n" );
99
+ sprintf (message , "XServer shutting down!\n" );
100
100
101
101
for (fd = 0 ; fd < num_clients ; fd ++ ){
102
102
write (fd_array [fd ], message , strlen (message ));
@@ -107,7 +107,8 @@ int main(int argc, char *argv[])
107
107
exit (0 );
108
108
}else {
109
109
for (fd = 0 ; fd < num_clients ; fd ++ ){
110
- write (fd_array [fd ], kbd_input , strlen (kbd_input ));
110
+ sprintf (message , "c%s" , kbd_input );
111
+ write (fd_array [fd ], message , strlen (message ));
111
112
}
112
113
}
113
114
}else if (fd ){//client socket
0 commit comments