Unix Programming - sending files through unicast sockets

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2004 > sending files through unicast sockets





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author sending files through unicast sockets
aelhhattabi

2004-11-24, 6:28 pm

Hi there,

I am doing some programming on sockets and I would like an introduction to
sending files through unicast sockets. I later will be making a program
that's a server and client that will allow people to search files on some
directory on my computer and get them if they are available. kinda like p2p
applications.
The idea is having a bunch of people connecting to the same multicast
network. a user would send a query looking for a filename. if the file is
found the owner would send him the requester the ip and port in order to
open a unicast connection to the owner. i have coded some parts of the
program but i dont know how to send a file. any help would be very
appreciated.


Måns Rullgård

2004-11-24, 6:28 pm

"aelhhattabi" <aelhhattabi@rogers.com> writes:

> I am doing some programming on sockets and I would like an introduction to
> sending files through unicast sockets. I later will be making a program
> that's a server and client that will allow people to search files on some
> directory on my computer and get them if they are available. kinda like p2p
> applications.
> The idea is having a bunch of people connecting to the same multicast
> network. a user would send a query looking for a filename. if the file is
> found the owner would send him the requester the ip and port in order to
> open a unicast connection to the owner. i have coded some parts of the
> program but i dont know how to send a file. any help would be very
> appreciated.


Use a TCP connection and sendfile().

--
Måns Rullgård
mru@inprovide.com
Dirty Vicar

2004-11-25, 5:53 pm

"aelhhattabi" <aelhhattabi@rogers.com> wrote in message news:<ZdCdnSWPUu8DhjjcRVn-uQ@rogers.com>...
> Hi there,
>
> I am doing some programming on sockets and I would like an introduction to
> sending files through unicast sockets. I later will be making a program
> that's a server and client that will allow people to search files on some
> directory on my computer and get them if they are available. kinda like p2p
> applications.
> The idea is having a bunch of people connecting to the same multicast
> network. a user would send a query looking for a filename. if the file is
> found the owner would send him the requester the ip and port in order to
> open a unicast connection to the owner. i have coded some parts of the
> program but i dont know how to send a file. any help would be very
> appreciated.


Not too hard, just do something like:

- open() the file
- read() a block of data from the file into a char buffer
- sendto() to the data from the char buffer
- continue until the file read() returns EOF
- close() file

Cheers,
dv
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com