Reading and Writing file on LAN

Hi gurus

I am not a C programmer but I need to read and write files on a computer on LAN using IP address.

Suppose on a computer that has an IP 192.168.0.2

Any help or code example. I did in JAVA using URL, but do not know how to do in ANSI-C.

In java:
-------
URL url = new URL("http://192.168.0.2/myfile.txt");
......
then reading from this URL file

Any one know the same process in ANSI-C

Regards
Lucky

When you use URL url = new URL("http://192.168.0.2/myfile.txt"); in Java you actually read the file with the help of HTTP protocol over TCP, to make this in C you need to

1) use sockets (SOCK_STREAM since we are using TCP protocol) to establish connection to the remote server 192.168.0.2 on port 80 (this is default for http protocol)
(see http://beej.us/guide/bgnet/output/htmlsingle/bgnet.html, the great tutorial for sockets programming)
2) you need to send HTTP GET Request to the server over created socket, e.g.

GET /myfile.txt HTTP/1.0
Host: 192.168.0.2

(see RFC 2616)
3) then you need to parse HTTP Response (if you lucky you just need to remove HTTP header, if not you need to decode base64 encoding, handle HTTP errors etc., all information about what you need to do written in HTTP Response header)
(see RFC 2616)

If you still want to recieve file from remote server in C program try some library for HTTP protocol, you can also use Perl or scp for instance.

I have gone through the tutorial you mentioned but was scratching my head.

Actually I am fairly new to C and a Java developer, only couple weeks with C. Any code sample example would be great help.

Secondly, I did not find any help once we are connected to socket.

You need to send HTTP GET Request to the server over created socket. And you recieve the HTTP REsponse through this socket.