BeginToLearn
asked on
command line may cause bugs
hi all,
After I updated my program to transfer everyting from src directory to dest directory by creating all hierarchy folder first ( new features) then transfer all files. I use the "system" command to creat new folder. However, I don't know how to make sure the "system" command finish before flow of program continue .I suspect it cause bug.
Current working dir: /home/ubuntu/program
directory is : /home/ubuntu/program/src/d ir1
directory is : /home/ubuntu/program/src/d ir1/dir2a
directory is : /home/ubuntu/program/src/d ir1/dir2a/ dir4
directory is : /home/ubuntu/program/src/d ir1/dir2
directory is : /home/ubuntu/program/src/d ir1/dir2/d ir3
ubuntu@ubuntu:~/program$ ./server
message2-> dirname is : /home/ubuntu/program/src/d ir1
message2-> dirname is : /home/ubuntu/program/src/d ir1/dir2a
message2-> dirname is : /home/ubuntu/program/src/d ir1/dir2a/ dir4
message2-> dirname is : /home/ubuntu/program/src/d ir1/dir2a/ dir4
/home/ubuntu/program/dest/ dir1/dir2a /dir4 is existed
message2-> dirname is : /home/ubuntu/program/src/d ir1/dir2/d ir34
received wrong size_to_read: No such file or directory
ubuntu@ubuntu:~/program$
Tks for your advise.
PS: one idea just pop up. in this case, the quick way is to check the directory existance after "system" command????
client.c
server.c
After I updated my program to transfer everyting from src directory to dest directory by creating all hierarchy folder first ( new features) then transfer all files. I use the "system" command to creat new folder. However, I don't know how to make sure the "system" command finish before flow of program continue .I suspect it cause bug.
Current working dir: /home/ubuntu/program
directory is : /home/ubuntu/program/src/d
directory is : /home/ubuntu/program/src/d
directory is : /home/ubuntu/program/src/d
directory is : /home/ubuntu/program/src/d
directory is : /home/ubuntu/program/src/d
ubuntu@ubuntu:~/program$ ./server
message2-> dirname is : /home/ubuntu/program/src/d
message2-> dirname is : /home/ubuntu/program/src/d
message2-> dirname is : /home/ubuntu/program/src/d
message2-> dirname is : /home/ubuntu/program/src/d
/home/ubuntu/program/dest/
message2-> dirname is : /home/ubuntu/program/src/d
received wrong size_to_read: No such file or directory
ubuntu@ubuntu:~/program$
Tks for your advise.
PS: one idea just pop up. in this case, the quick way is to check the directory existance after "system" command????
client.c
server.c
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oh tks Sara. I am also rework on my get_all_files(). Testing now :)
good job :)
one last remark,
if you would clear the static buffer after each message the buffer automatically would be zero-terminated in case of text messages.
Sara
one last remark,
if you would clear the static buffer after each message the buffer automatically would be zero-terminated in case of text messages.
Sara
ASKER
oh you mean after I receive the message, i should clear the static buffer? Is it same effective like i use memset() to set static buffer before receving message?
no, my fault, you can't clear it after the message cause the buffer was returned to the caller. but you can do memset before the while loop.
because maximum message length is 2048 and the buffer is 2049 you always have at least 1 zero char left if you do proper initialisation before recv. for message 3 that is irrelevant cause it may contain binary data as well. but for string message like message 2 it makes the handling (and debug output) simpler.
Sara
because maximum message length is 2048 and the buffer is 2049 you always have at least 1 zero char left if you do proper initialisation before recv. for message 3 that is irrelevant cause it may contain binary data as well. but for string message like message 2 it makes the handling (and debug output) simpler.
Sara
ASKER
I get the idea. tks. Let me close this question. I will rework to make it sending to multiple server.
Sara