Re: Transfer files using sockets, urgent!!



petekevin@xxxxxxxxx wrote:
> Stuff.

A couple of things...

1) Why is your sending code called recv.c and your receiving code
called send.c?

2) Your file sending is very very basic:

A) Open a listening socket on host A
- If you get a connection...
--> while (1) { read (socket), write (fd) }

B) Open an out going port from host B to target
- If you successfully connect...
--> while (1) { read (fd), write (socket) }

It really doesn't get much more efficient (or basic) than that.
If you want to speed things up you could -try- using UDP to
send some data and TCP for header information...? I doubt you'll
get a massive performance improvement over what you've already
achieved.

3) Your connect problem could be any number of things. Try
looking at the errno after the connect fails.

(look here: http://bama.ua.edu/cgi-bin/man-cgi?connect+3SOCKET)

It could be anything but I'd guess ECONNREFUSED or ETIMEDOUT.

4) What was the fourth thing again...? I can't recall. Ah, I suggest
you look at using a non-blocking socket approach, otherwise your
network code is going to end up having to be put in it's own thread
to avoid the application hanging when the network blocks...

5) Woa! Did you say 2 gig in under 4 minutes? You realize that's a
transfer rate of er... no calculator... 8 megabytes a second?
Its been a while, but isn't a 100 Mbit connection only capable
of doing 1 meg / second? Are you on a fiber-optic network or
something? Otherwise you're probably being speed limited by the
network hardware you have... (If I have my numbers wrong, someone
please correct me...)

ciao,
D.
.