# ftp application using socket programming

**URL:** <https://community.unix.com/t/ftp-application-using-socket-programming/156245>\
**Category:** Programming\
**Created:** [September 23, 2005, 1:39pm UTC](https://community.unix.com/t/ftp-application-using-socket-programming/156245 "2005-09-23T13:39:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![toughguy2handle](https://community.unix.com/letter_avatar/toughguy2handle/32/6_22734026db12803ebb3e059622ac3534.png) [@toughguy2handle](https://community.unix.com/u/toughguy2handle)\
**Post date:** [September 23, 2005, 1:39pm UTC](https://community.unix.com/t/ftp-application-using-socket-programming/156245/1 "2005-09-23T13:39:17Z")

</div>

i have made a ftp application in socket programming which uses TCP/IP .. i have the problem runing the only problem is on the client side i take the user input for the file to be downloaded from the command promt.

write(s, argv[2], strlen(argv[2])+1); // this is how i write in client side  
argv[2] is reading the file name  
read(sa, buf, BUF\_SIZE);// how i read in server side  
sa is the variable for newsockfd  
the only from problem is if the user requests for a file which does not exist .. how to put a error condition for it and how to chck it..

i

---

<div class="post-metadata">

**Author:** ![blowtorch](https://community.unix.com/user_avatar/community.unix.com/blowtorch/32/136_2.png) [@blowtorch](https://community.unix.com/u/blowtorch)\
**Post date:** [September 23, 2005, 10:47pm UTC](https://community.unix.com/t/ftp-application-using-socket-programming/156245/2 "2005-09-23T22:47:53Z")

</div>

You can just try to open the file in any case. Suppose you are using the open system call, then opening a file that does not exist will return -1 and the errno variable will be set with "ENOENT". When this happens, you can return an error to the client saying that the file does not exist.
