TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sameera Athukorala
NA
4
869
how to identify Sever and client in a given code
May 6 2017 1:13 PM
#include <header.h>
int copy (char *srcm char *dst) { /* procedure to copy file using the server */
struct message m1 ; /* message buffer */
long position ; /* current file position */
long client =110; /* client’s address */
initialize () ; /* prepare for execution */
position = 0 ;
do { /* Get a block of data from the source file */
m1.opcode = READ ; /* operation is read */
m1.offset = position ; /* current position in the file */
m1.count = BUF_SIZE ; /* how many bytes to read */
strcpy(&m1.name, src) ; /* copy name of file to be read to message */
send (FILE_SERVER, &m1) ; /* send the message to the file server */
receive (client, &m1) ; /* block waiting for the reply */
#include <header.h>
void main(int argc, char **argv) {
struct message m1, m2 ; /* incoming and outgoing messages */
int r ; /* result code */
while (1) { /* server runs forever */
receive (FILE_SERVER, &m1) ; /* block waiting for a request */
switch (m1.opcode) { /* dispatch on type of request */
case CREATE : r = do_create(&m1, &m2) ; break ;
case READ : r = do_read(&m1, &m2) ; break ;
case WRITE : r = do_write (&m1, &m2) ; break ;
case DELETE : r = do_delete (&m1, &m2) ; break ;
default : r = E_BAD_OPCODE ;
}
m2.result = r ; /* return result to client */
send (m1.source, &m2) ; /* send reply */
}};
Reply
Answers (
1
)
umm... a little bug i think
Check on login page to enable / disable users