UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2006-10-22 11:26 AM

tomcio
Member
From: Poland
Registered: 2006-08-14
Posts: 113

Re: Win32 and file descriptors?!

Offline

#2 2006-10-22 12:59 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Win32 and file descriptors?!

MSWindows is not Unix. Filedescriptors are a unix thing. The functions you mentioned are POSIX functions. What are supported are C file functions like fopen etc.

As for your read() problem, read doesn't necessarily fill your whole buffer at once, so just call it again for the remaining data. How much it did read will be returned.

Offline

#3 2006-10-22 02:22 PM

tomcio
Member
From: Poland
Registered: 2006-08-14
Posts: 113

Re: Win32 and file descriptors?!

data->file = g_fopen (file_path, "r");
    if (data->file == NULL) {
        gui_show_message_dlg (GUI_WARNING, _("Faild to send file"),
            _("Can't open file, which you want to send."));
        goofy_send_file_free (data);
        return NULL;
    }

Offline

#4 2006-10-22 05:45 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Win32 and file descriptors?!

Is this a binary file, by any chance?  If so, I think you need to use "rb" instead of
just "r" in your fopen(), because Windoze stupidly treats text files differently than
binary files...

(And, I thought the raw FD-based I/O functions were standard everywhere there
was a C implementation...  But, you know, leave it to MS to screw something up, if
anyone can... *shrug*)

(Oh, and Michael, did you really go and add MS to the censor list, as I was joking
about in a previous thread??  Based on the link in the first post here, I'm guessing
yes... ;-))

Offline

#5 2006-10-23 06:46 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Win32 and file descriptors?!

You didn't set data->file_size correctly. Or do you really have a 734 Mb big file?

Other than that the output is as expected. The first call your whole buffer is filled, the second call the remaining data is read. I think your real filesize is 10309.

(I can't find 'microsoft' in the censored words list (which is empty), so either Michael is cunning or tomcio is having a big laugh. Or I'm blind or the software is buggy of course.)

Offline

#6 2006-10-23 08:55 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Win32 and file descriptors?!

(It was in there...  I checked and removed it after posting my comment...  Michael
was obviously being a smart-ass... ;-))

Offline

#7 2006-10-23 09:07 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Win32 and file descriptors?!

Well, I must admit, it has aesthetic advantages. ;-)

Offline

#8 2006-10-29 02:41 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Win32 and file descriptors?!

>> Trying to look innocence <<


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

Board footer

Powered by FluxBB